Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange behavior of Select
Message
From
27/11/2012 06:13:03
 
 
To
27/11/2012 06:05:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01558144
Message ID:
01558152
Views:
61
>>I was just notified of a very strange behavior of the Select command and the Select() function, by Maharastra Kolhapur on Foxite. What he told me, and which I didn't know, was that Select() also performs an implicit Select command "behind the scene" when you supply a work area that is actually used. And even "worse", VFP makes no distinction between Select(myWorkArea) and Select (myWorkArea), note the space, they both are treated as Functions!
>>
>>Here is a small, slightly modified, excerpt from my message on Foxite. Please read carefully, the impact may be bigger than you immediately think.
>>myWorkArea = 'myTable' && myTable is already used in another work area
>>1. ?Select(myWorkArea) && Function
>>2. ?Select (myWorkArea) && Function or Command? Looks like a command but is treated as a function. 
>>3. Select (myWorkArea) && Function or Command? Looks like a command but is treated as a function. 
>>
>>Note that the only difference between 1 and 2 is the space. I would expect an error on 2.
>>And that the only difference between 2 and 3 is the question mark.
>>Since we have the "option 3", maybe it's a good thing that Select() also performs an implicit Select command?
>>
>>I am really grateful for your discovery, which I will keep in mind. Luckily we have the debugger.
>
>The space between select and the left parenthesis is insignificant space which the lexer does not pass to the parser
>
>When select is not the first word, it's a function otherwise a command. The parser has some rules to determine whether it's a select command or an sql select

You are right, and I accept that I was partly wrong. Anyway, I find it a little confusing that the parser behaves this way, since it's legal to call a function without using the returned value.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform