Conditional structures: Difference between revisions

Line 2,827:
 
=={{header|M2000 Interpreter}}==
===[IFIf THENThen ELSEElse.IFif ELSEElse]===
<lang M2000 Interpreter>
Module CheckIt {
Line 2,844:
</lang>
 
===[IF() ANDand IF$() - Ternary]===
One expression evaluated only. We can use If$() to use string expressions
<lang M2000 Interpreter>
Line 2,865:
</lang>
 
===[SELECTSelect CASECase]===
We can use string, and three types of cases (all of them in one case), >1000, 10 to 40, 400
<lang M2000 Interpreter>
Line 2,886:
CheckIt -100
 
</lang>
 
 
===[Conditional loops]===
<lang M2000 Interpreter>
x=10
While x>0 {
Print x
x--
}
Do {
x++
Print x
} Until x=10
 
</lang>
 
 
===[On Goto, On Gosub]===
<lang M2000 Interpreter>
Module CheckIt {
For i=1 to 10 {
x=Random(1,2)
{
On x Goto alfa, beta
alfa:
Print "ok1"
Exit
beta:
Print "ok2"
Exit
}
Print "End One"
x=Random(1,2)
{
On x Gosub alfa1, beta1
Exit
alfa1:
Print "ok1"
Return
beta1:
Print "ok2"
Return
}
Print "End"
}
}
CheckIt
</lang>
 
Anonymous user