The keyword 'other' to indicate the switch's default branch has been renamed to 'any'. With these changes, the by-switch statement has become concise and very flexible.
Code: Select all
' SharpBASIC 'by' switch example with fall, next and done
' -------------------------------------------------------
option strict;
incl "lib/sys.sbi";
dim n: int = 1;
main do
by n
is 1, 4, 5 do
print("this is one");
fall; ' skip next condition and execute its block
is 2 do
print("this is two");
n = 3;
next; ' test next conditions, execute 'any' if no match
is 3 do
print("this is three");
done; ' exit switch statement
is 7 to 10, 12 do
' If this block is executed the 'any' branch can be executed with
' 'fall' or 'next'
print("this is four");
fall;
is any do
print("this is any");
end
end