Which version did you pick - the original or new one? In the new one (simpler, IMHO) pnRec initially is set to 0.
In the original it was set to -1 initially.
The idea again is
if we're in the same group, then simply increment pnRec. Once the group changes, reset pnRec to 1.
I'm using NVL because _VFP.SetVar returns NULL. So, it is a function call inside the IIF test.
It may be not a very good code and could be possible broken. Write your own code using scan/endscan instead.
>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
If it's not broken, fix it until it is.
My Blog