Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with code
Message
 
 
To
29/11/2001 00:40:56
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00587201
Message ID:
00587451
Views:
30
Hi Dragan,

I tried this solution by myself, but it seemed to not work (I did only one test, though), so I switched to another index, which was simpler (just a concatenation of character fields).

>>Hi everybody,
>>
>>In BatchCntrl table I have an index in Bintoc(DsID)+ExtrYear+ExtrWeek.
>>
>>I'm passing DsID as a parameter in a form method. Here is a piece of code:
>>
>>lcIssue = .ThisIssue
>>	select BatchCntrl
>>    lcOldOrder = order()
>>    set order to DsIDWeek
>>*    BINTOC(dsid)+extryear+extrweek
>>    lcFor = iif(vartype(m.tnDsID)="N",;
>>            [for bintoc(DsID)+extryear+extrweek=bintoc(tnDsID)+lcIssue], ;
>>            [for State+ExtrYear+ExtrWeek=']+ m.lcStateWeek+['])
>>	scan &lcFor
>>This doesn't seem to work. Originally I have
>>
[for bintoc(DsID)+extryear+extrweek=']+bintoc(tnDsID)+lcIssue+[']
, ;
>>which gave me error on SCAN line. lcFor contains some symbols, which probably & can not recognize.
>>
>>What can I do here? Change it to separatly use DSID and ExtrYear, ExtrWeek (e.g. don't use DsIDWeek index). I probably can add two more indexes in my table to still use Rushmore optimization.
>
>The reason the initial For clause didn't work is the macro substitution where you tried to put a result of a BinToC() into a literal. BinToC() generally creates an unpredictable binary content, and while VFP may tolerate any content in the strings, I'm not sure of the content in the string constants (which is what you got after macro expanded).
>
>I was using BinToC() in indexes for a while, and sometimes they are the only solution that's quick enough. The function itself is probably just a few lines in C++, so it should not introduce more overhead than using, say, upper().
>
>The way around your problem is not to use the string literals in the macros, but use a variable:
>
lcRightSide=bintoc(tnDsID)+lcIssue
>lcFor=[for bintoc(DsID)+extryear+extrweek=lcRightSide]
>I'm not sure whether the right side of the condition would or would not be recalculated for each record, but this way it surely would not be.
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