Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
No Duplicates
Message
 
 
To
05/05/2010 10:38:15
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01462570
Message ID:
01463217
Views:
23
>Ok lets see
> select the table, set an index declare variables
>
>Then you Replace the IDfield(the ton of Zeroes granted we didnt do the previous replace) with if and only if the test.fname=m.pcname.
>
>NVL returns statement 2 if statement 1 is null.
>
>so NVL(_VFP.setvar('pnRec',m.pnRec+1),1)= Setvar sets a variable to a value pnrec an pnrec+1 i would believe but if null 1 is returned?
>
>NVL(_VFP.SetVar('pcName', crsTest.FName),1)=same as above mostly but different expressions for 1 and 2
>
>
>* NVL(_VFP.SetVar('pnRec', 0),1)) * (m.pnRec + 1) IN crsTest NEXT 40= pnrec an 0 is the first expression and if null sis returned 1 is returned?
>*(mpnrec+1) not too sure and also not sure about NEXT 40

Instead of next 40 try WHILE NOT EOF(). I wanted to make sure that the replace runs in the order I specified. NEXT respects the order set, replace ALL doesn't seem to respect the order.

The idea of manipulations with _VFP.SetVar is to increment the counter if we're in the same group and reset to 0 if the new group starts.

_VFP.SetVar returns NULL. So I use NVL and convert the return value to 1

Essentially, it translates to
   IF Same group
      pnRec = m.pnRec + 1
  else
    pnRec = 0
endif
and the result of my function always would be 1, so I can use it to multiply.

Perhaps the same idea can be translated into slightly different code, I did the first that came to mind.

Yes, I'm thinking this code can be changed to
IDField 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)))
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform