Sometimes I wish BASIC were just like Lua or Pascal, insisting only on boolean result out of "IF... THEN".
Because it's not, because it's zero for "false" and any other value for "true", I have to design things with the first form. Like I said, I'm trying to think of a good way which has a complex "boolean" expression. Yet I'm not that confident neither in doing it in Lua, and that interpreter has given me problems with some of my ineffective designs.
Another thing is that QB64(PE) doesn't (yet) feature short-circuit evaluation, while Lua does. If it did, then even more things could be done with only one "IF" in the huge "IF... THEN... ELSEIF... ELSE... END IF" block. I wouldn't like short-circuit evaluation supported with "ANDALSO" and "ORELSE" keywords though, better with a compiler switch, if the aim isn't to be compatible with Freebasic and Visual Basic code.
Another thing is to gather the "IF" and "ELSEIF" stacks carefully when testing the same variable. Consider:
Code: (Select All)
IF i > 5 THEN
:
ELSEIF i > 10 THEN
:
END IF
What if you want code posted under "i > 10" to be executed while "i" is eleven at least? Instead of code that is executed in the first section? Something like this is a common mistake made with "IF... THEN... ELSEIF... ELSE... END IF". This was just an example with one variable involved, which could be rewritten with "SELECT CASE... END SELECT". But there is code which need to test two or more variables at the same time and relying on function results and other stuff.
Block "IF" is one of the best things that ever happened to BASIC. Together with looping structures and real subprograms, it made "GOTO" and line numbers unnecessary.
LOL Steve will answer you with more detail soon.