Someone on IRC asked if there was a way of doing something similar to the switch keyword in PHP/C++ etc... I couldn't think of an easy way but came up with this:
Code: Select all
10 let case=6
20 if case<7 then on case gosub 100, 120, 140, 160, 180, 200:if case>0 then goto 40
30 print "default"
40 end
100 print "condition 1"
110 return
120 print "condition 2"
130 return
140 print "condition 3"
150 return
160 print "condition 4"
170 return
180 print "condition 5"
190 return
200 print "condition 6"
210 return
Code: Select all
10 get case$: if case$<"0" or case$>"6" then goto 10
15 case = val(case$)
20 on case gosub 100, 120, 140, 160, 180, 200:if case>0 then goto 40
Regards,
Shaun.