I agree, but that still doesn't explain why only a single record would be returned by:
lcTest=[playerno]
SELECT * from entrylist WHERE EVALUATE(lcTest) = 4 && One Record returned
...appears to be working and no longer referencing the active record in entrylist, however that's not the case since:
lcTest=[playerno]
SELECT * from entrylist WHERE EVALUATE(lcTest) = 1 && No Records returned
...I cannot come up with a logical explanation for this. The fact that evaluate() is referencing the current record in entrylist explains every case except this one. If this example fit the mold, the first SQL statement having EVALUATE(lcTest) = 4 in it's where clause would return all records, not just one, since as you say it is equivalent to having "Where .T.".
jimoo, your code example works because it's completely inside the loop. As I recall some languages warn about changing values controlling the loop, I think JavaScript was one that comes to mind.
Code:
FOR lni = 1 to EVAL(lnMax)
lcTable2Open = arTable2Open[lni]
SELECT 0
USE (lcTable2Open)
IF ALIAS()<>""
lnMax=lni && this assignment probably doesn't force exit
ENDIF
ENDFOR
Another example could be this one where the value passed is the data contents and is evaluated only once at the entry point.
DO myProg WITH (myVar)
Apparently there is some initial evaluation that is done in the SQL's WHERE clause that is not repeated within the command. Interesting little quirks, aren't they?
As I recall some languages warn about changing values controlling the loop...
You're right, change the controlling value of a loop will cause a problem in any language.
In VFP this is often caused by the system variable _TALLY variable - such as
FOR lni = 1 TO _TALLY
and _TALLY is later changed as a result of another operation.
However, I don't think that is the question and none of the prior examples in this thread deal with the controlling value. It is whether the & or () work.
I think the example I provided demonstrates either can work, but () is usally more efficient and the value can change as with &.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.