Changes

Locomotive BASIC

891 bytes added, 13:25, 19 September 2011
/* IF THEN ELSE */
==== <code>IF THEN ELSE</code> ====
: [Asks for a choice with the '''IF...]THEN...ELSE''' statement.: '''IF''' compares the entry condition in a logical way: '''THEN''' contains instruction if the comparison is true: '''ELSE''' contains instruction if it's false.: '''Example:'''<pre>10 INPUT "guess a figure:",f20 IF f=10 THEN PRINT "right": END: ELSE GOTO 10</pre>: In case of nested choices there's a possibility to that with an IF...THEN instruction but not very recommended:<pre>10 INPUT "guess a figure:",f20 IF f=10 THEN PRINT "right": END: ELSE IF f<10 THEN PRINT "too small" ELSE PRINT "too big"30 GOTO 10</pre>:Other nested structures like IF...THEN...'''ELSE...ELSE''' won't work first because the Locomotive Basic only looks after the first ELSE instruction found and can't execute more single commands as a block for a certain condition in comparision to e.g. "PASCAL" > begin...end-block, "C" > {...}-block.
==== <code>INK</code> ====
205
edits