Flow-control structures: Difference between revisions

Content added Content deleted
No edit summary
Line 1,327: Line 1,327:
long x=random(1, 2)
long x=random(1, 2)
on x goto 90, 100
on x goto 90, 100
090 print "can print here if is "+x // if x=1
090 print "can print here if is "+x // if x=1
100 Print "ok"
100 Print "ok"
gosub 500
gosub 500
alfa: // no statement here only comments because : is also statement separator
alfa: // no statement here only comments because : is also statement separator
print "ok too"
print "ok too"
integer c
integer c
Line 1,339: Line 1,339:
}
}
print "no print here"
print "no print here"
200 Gosub exitUsingGoto
200 Gosub exitUsingGoto
Every 100 { // every 100 miliseconds this block executed
Every 100 { // every 100 miliseconds this block executed
c++
c++
Line 1,349: Line 1,349:
on x gosub 400, 1234
on x gosub 400, 1234
}
}
if ok else print error$ // sub not found (display this message if x=2)
if ok else print error$ // sub not found (if x=2)
goto 1234 ' not exist so this is an exit from module
goto 1234 ' not exist so this is an exit from module
400 print "can print here if is "+x // if x=1
400 print "can print here if is "+x // if x=1
end
end
printc:
printc:
Print c
Print c
return
return
500 Print "exit from block using exit" : return
500 Print "exit from block using exit" : return
exitUsingGoto:
exitUsingGoto:
Print "exit from block using goto"
Print "exit from block using goto"
return
return
Line 1,363: Line 1,363:
Inner
Inner
</syntaxhighlight>
</syntaxhighlight>




=={{header|Mathematica}} / {{header|Wolfram Language}}==
=={{header|Mathematica}} / {{header|Wolfram Language}}==