Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
No Duplicates
Message
From
05/05/2010 12:00:25
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01462570
Message ID:
01463253
Views:
32
>>O_0 but the orginal version didnt exactly work it told me function name missing
>
>Worked fine for me. I posted you the exact script I tested.
>
>Here is the test with the changed code
>
>LOCAL lnI
>CREATE CURSOR crsTest (IDFld I, FName c(10))
>FOR lnI = 1 TO 10
>  INSERT INTO crsTest (FName) VALUES ('Ken')
>  INSERT INTO crsTest (FName) VALUES ('David')
>  INSERT INTO crsTest (FName) VALUES ('Michael')
>  INSERT INTO crsTest (FName) VALUES ('Robert')
>NEXT
>
>INDEX on fName TAG fName
>
>PRIVATE pnRec, pcName
>
>pnRec = -1
>pcName = crsTest.FName
>
>*!*	replace IDFld WITH IIF(crsTest.FName == m.pcName, NVL(_VFP.SetVar('pnRec', m.pnRec+1),1), ;
>*!*	NVL(_VFP.SetVar('pcName', crsTest.FName),1) * NVL(_VFP.SetVar('pnRec', 0),1)) * (m.pnRec + 1) IN crsTest WHILE NOT EOF()
>
>replace IDFld with IIF(pcName = crsTest.fName, nvl(_VFP.SetVar('pnRec',m.pnRec+1), m.pnRec), ;
>nvl(_VFP.SetVar('pcName',crsTest.fName),1) * nvl(_VFP.SetVar('pnRec',1), m.pnRec)) WHILE NOT EOF()
>browse
yay it works!!! you>all
but im still trying 2 understand the logic.

lets say we have three instances of the name Peter.
NVL(_VFP.setvar('pnRec',,.mpnREC+1),) this first expression evaluates to Zero right? (i changed ur pnrec to -1) an expression 2 is=1 therefore the 1st instance of peter gets 1.
Line 2
nvl(_VFP.SetVar('pcName',crsTest.fName),1) Expression 1 is 0 or null? so we move to expression 2 to which is 1.
so 1 * 1 since we moved too expression 2 * by pnrec+1

?
is this close to it? btw im reffering too your commented code
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform