fxm wrote:
(for all syntaxes, the expressions inside brackets are optional)
Look this expression in bold is inside brackets:
If expression Then [statement(s)] [Else [statement(s)]] [End If]
So it seems possible to write no more no less than:
The second point is not for abusing your patience, but "statement(s)", sincerely doesn't make this obvious that this means also something containing series of statements separated with commas,
AND without END IF. It is in contradiction with the second line.
And the second line itself seems broken (just focus at the comma):
Code: Select all
#define expression i=0
#define statements ? "in ": ? "the " : ? " if" : ?
dim as integer i = 1
If expression Then : statements
? "out of if"
sleep
In fact this is even more difficult to guess that "statement(s)" hide commas, when in the second line the comma is exhibited (and broken?).
And in all case, the problem is with the "commas", and the fact that
they allow omitting END IF.
This is something that I wouldn't do myself, but I've found examples of codes with those syntax and I simply couldn't know where the IF ended. Even worst, I could rewrite two version of the code that compiles depending on the choice made, but obviously breaking the code if misinterpreted:
Code: Select all
'example from the forum
While I <= J
While array(I).z > X .z:I+=1:Wend
While array(J).z < X .z:J-=1:Wend
If I<=J Then Swap array(I),array(J): I+=1:J-=1
Wend
As you see that can be very involved to read an algorithm if the rules are not really clear with single line IF. You can notice that the While bloc would require a END WHILE. So this is not possible to infere the right rule for IF by simply comparing. The doc is in this case mandatory.