O2 is so cool!
In O2, I can write:
if condition1 then: statment1
elseif condition2 then: statement2
else: statement3
end if
In _every_ other Basic I've tried (QB, QB64, FreeBasic, QBJS, SmallBasic, YABasic, BAM) I have to write:
if 0 then
elseif condition1 then: statement1
elseif condition2 then: statement2
else: statement3
end if
In order to distinguish a single-line "if" from a multi-line "if".
So how does O2 recognize that "if condition1 then: statement1" is the start of a multi-line "if" statement and not a single-line "if" statement?
p.s. Still making good use of the "select" without a condition statement! Thanks for adding that!
Hi Ed,
It's the colon that breaks the logical line and causes the multiline interpretation.
'then' is only required for single liners. Otherwise it is ignored.
So this works too: :)
int a,b,c
a=5
b=5
if a<b : c=1
elseif a=b : c=2
elseif a>b : c=3
endif
print c
Yes, I remeber the case tweak. This performs the same way:
int a,b,c
a=5
b=5
select a
case a<b : c=1
case a=b : c=2
case a>b : c=3
end select
print c