3 levels categories

3 levels categories

Postby Silvio.Falconi » Sun Apr 21, 2013 4:25 pm

I'm thinking to create 3 levels of categories for a store

Level 1 : 2 Characters (es. 11)
Level 2 : 2 Characters (es. 1122)
Level 3 : 4 Characters (es. 11223333)


sample :

cCodice:= 01020001

cDesc := Italian keyboard black

I have some problems to build valid at get when the user insert a new record because the valid function must to control if there is the higher-level of the code he inserted

Isample : if the user insert the code := 01020001

he must insert before 01 keyboard, 0102 Italian Keyboard and then he can insert the new category

Any help please to build the valid function
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6865
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 levels categories

Postby ADutheil » Sun Apr 21, 2013 4:44 pm

You can split the get into 3 gets so you can validate them separately.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: 3 levels categories

Postby Silvio.Falconi » Sun Apr 21, 2013 5:11 pm

sorry I have allready the dbf, and I must use this (from customer) look this :

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6865
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 levels categories

Postby Antonio Mart. » Sun Apr 21, 2013 6:12 pm

Silvio,

Here at the levels we call families of items.

So you should have your stored configuration in a field the levels of your families of items.

Example:
If your levels are 2,2,4 you can store "020408"
To find that there are higher levels of hierarchy you can use:

Code: Select all  Expand view

FUNCTION lExistLevels(cItem)
Local lExist:= .f.
Local cLevels:= "020408" // From config field
Local nMaxItem:= Val(Right(cLevels, 2))
Local nI, nAt:= At(StrZero(Len(cItem), 2), cLevels)- 2    
Local nLevel, cSubItem
FOR nI:= 1 TO nAt STEP 2
   nLevel:= SubStr(cLevels, nI, 2)
   cSubItem:= Left(cItem, nLevel)
   SELECT Items
   SEEK PadR(cSubItem, nMaxItem)
   IF Eof()
       lExist:= .f.
       EXIT
   ENDIF
   lExist:= .t.
       
NEXT
RETURN lExist
   
Regards
   
 
Antonio Mart.
 
Posts: 174
Joined: Sat Feb 23, 2013 10:04 am

Re: 3 levels categories

Postby Silvio.Falconi » Sun Apr 21, 2013 7:27 pm

perhaps it is that I'm searching... I must make some tests
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6865
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 levels categories

Postby Silvio.Falconi » Sun Apr 21, 2013 8:14 pm

Antonio Mart.,
the function can run ok only when I digit a string of 8 Cr the function run ok
if I digit a string of 6 cr it is bad code I can have only 3 levels

for sample
aa
aabb
aabbcccc

the function must return a string aabbcc as right ...
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6865
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 levels categories

Postby FranciscoA » Mon Apr 22, 2013 12:04 am

Silvio.
You can do this:

Static nLenCode := 8

Redefine get oget var cvar id 4000 of odlg Valid cCodeOk(cvar)

Function cCodeOK(cVar)
if !MyCatal->(dbseek(cVar)) .or. len(alltrim(cVar)) != nLenCode
Stop("Bad code inserted")
return .f.
endif
Return .t.

This is only for transactions validations.
I hope it helps you.

Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2114
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: 3 levels categories

Postby ADutheil » Mon Apr 22, 2013 12:30 am

The DBF does not matter.

get var1 valid ...
get var2 valid ...
get var3 valid ...
read

field_to_save := var1 +var2 + var3
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests