FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour 3 levels categories
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
3 levels categories
Posted: Sun Apr 21, 2013 04: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 March-April 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
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: 3 levels categories
Posted: Sun Apr 21, 2013 04: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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: 3 levels categories
Posted: Sun Apr 21, 2013 05:11 PM
sorry I have allready the dbf, and I must use this (from customer) look this :

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 174
Joined: Sat Feb 23, 2013 10:04 AM
Re: 3 levels categories
Posted: Sun Apr 21, 2013 06: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 (fw): Select all Collapse
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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: 3 levels categories
Posted: Sun Apr 21, 2013 07: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 March-April 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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: 3 levels categories
Posted: Sun Apr 21, 2013 08: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 March-April 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
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: 3 levels categories
Posted: 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
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: 3 levels categories
Posted: 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

Continue the discussion