10-24-2022, 11:18 AM
(This post was last modified: 10-24-2022, 11:23 AM by mnrvovrfc.
Edit Reason: In Lua equality operator is two equalsigns not one, sorry
)
(10-23-2022, 03:38 PM)Dimster Wrote: :I've seen something like this in somebody else's program which infuriated me. Even though it works and most BASIC interpreters accept it.
or if there may be a couple within the controlled range is there a way to
For x = 50 to -50
if x = 10 or x = 0 or x = -10 then Next
Next
Using "NEXT" like that could cause outright confusion, for debugging the program many moons later or for somebody else who must look at the program, if the variable is never provided after "NEXT" and code is not commented. Try going three or more levels of "FOR... NEXT" nesting and using "NEXT" instead of "_CONTINUE". I guess the Freebasic developers dreaded that and that's why after "CONTINUE", in their product must specify which leading loop statement, just like with "EXIT". Also they have "EXIT SELECT" which I can't conceive a purpose. So much fuss only to have local variables inside an "IF... END IF" or "SELECT CASE... END SELECT" block.
Without "_CONTINUE" I found the example program in "DO... LOOP" in the Wiki very clever. Having "_CONTINUE" around makes programs more readable, however.
I have a weakness that sometimes I don't trust boolean evaluation even in Lua, which makes me write a condition that I want false so that something is executed. So often I'm doing something like:
Code: (Select All)
if a == 5 then
-- do nothing
else
-- do something important
end
In Lua could safely rewrite to "if not a == 5 then" or "if a ~= 5 then" but of course, in many program-scripts I wrote it's more complex than that. :/
(10-24-2022, 12:11 AM)Pete Wrote: :I have done the same thing, and I have even written a "preprocessor" for QB64 trying to fake "_CONTINUE" in that manner. It was difficult figuring out block "IF" statements which was the main reason why my attempt failed. :/
I have to admit in some code of mine dated back to 2000 I've found the classic...
Code: (Select All)FOR I = 1 TO 10
IF I = 2 OR I = 8 THEN GOTO BYPASSI
PRINT I
BYPASSI:
NEXT