Hello Charles. I have this code in PluriBASIC (database support):
FOR EACH Usr WHERE "admin=1"
printbr "Record #" & format$(Usr.id) & " retrieved correctly."
NEXT Usr
It is being converted to something like this:
for (database.load(Err, 1, @usr, "admin=1"); database.next(Err, 1, @usr); database.count()) {
print "Record #" + ¤FORMAT(EXE.lng(@usr, 0), byval 0) + " retrieved correctly."
}
But oxygen is complaining about this:
ERROR: ERROR: Missing '='
WORD: database.load
IN: pbmain
LINE: 2157
FILE: "main source
I am guessing Oxygen is expecting a counter to be setup... but not always a counter is setup in C++ style blocks.
AFAIK, any statement should be allowed there, as well as the incrementer, any statement should be allowed there. In other words
the c style for/next blocks should allow three sections (in this order):
- An initial setup statement (not necessarily a counter setup like: i=0).
- A situation that should be TRUE so that the loop continues (loop should break as soon as it becomes false).
- Anything that can be used as incrementer, even a function call.
In this case, i am using database.load() as the initial setup. Then database.next() returns TRUE as long as there are more records loaded. and database.counter() which currently does nothing but is prepared for future features.
Note that all functions work properly individually... but the for initializer is expecting me to setup a counter variable (i am guessing).
Not forcing a counter setup (for example: counter = 0), would make this statement more versatile.
Note: I got it to compile by setting a dummy (unused) counter like this:
for (¤CNTR = database.load(Err, 1, @usr, "admin=1"); database.next(Err, 1, @usr); database.count()) {
But IMO, i think even the following could be a valid statement:
for (;1;) {
' determine conditions for breaking the loop here.
}