Code: Select all
dim as boolean a
'a = true
if a then print "5" : print "again"
The [print "again"] is part of the if statement.
(bold:mine)In the -lang fb and -lang fblite dialects, if there is a new line, a single-line comment ('), a colon (:), or a Rem statement directly after THEN, then the IF will be multi-line. Any other statement will result in a single-line IF.
The word "directly" is unambiguous. The colon is NOT directly after THEN.
Multiline IF requires an END IF to terminate.
I read this with the implication that any valid FB syntax directly behind the THEN that is NOT a statement would trigger the multiline.
Is this a poor choice of words, a misunderstanding on my part, a parser fail, an undocumented feature?
I have searched for a language syntax guide to describe the function seperator : but could not find one. Is there one?
The only reference to using a colon to 'stacking' statements on one line is in the https://www.freebasic.net/wiki/ProPgExpressionsStatements page.
I found the IF tutorial by rdc, and I do find this usage in an example of his.
I'm not bothered by this. I saw someone else's use of this pattern in the forum and was puzzled. I had to test it to be sure what was happening, and the IF doc implies this should not work. I think.
I don't want to be seen attacking the wording in the manual.
I just wonder if others might see it this way, also. If so, then some tiny change in wording would be appropriate.
At least, an added SIMPLE example on the IF page to show this usage would provide a reference if someone else has the same puzzlement.