RosettaCodeData/Task/Conditional-structures/Run-BASIC/conditional-structures.basic

81 lines
923 B
Plaintext

' Boolean Evaluations
'
' > Greater Than
' < Less Than
' >= Greater Than Or Equal To
' <= Less Than Or Equal To
' = Equal to
x = 0
if x = 0 then print "Zero"
' --------------------------
' if/then/else
if x = 0 then
print "Zero"
else
print "Nonzero"
end if
' --------------------------
' not
if x then
print "x has a value."
end if
if not(x) then
print "x has no value."
end if
' --------------------------
' if .. end if
if x = 0 then
print "Zero"
goto [surprise]
end if
wait
if x = 0 then goto [surprise]
print "No surprise."
wait
[surprise]
print "Surprise!"
wait
' --------------------------
' case numeric
num = 3
select case num
case 1
print "one"
case 2
print "two"
case 3
print "three"
case else
print "other number"
end select
' --------------------------
' case character
var$="blue"
select case var$
case "red"
print "red"
case "green"
print "green"
case else
print "color unknown"
end select