Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with code
Message
From
29/11/2001 00:40:56
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00587201
Message ID:
00587340
Views:
33
This message has been marked as a message which has helped to the initial question of the thread.
>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.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform