21.11.2014 Views

Programming Manual for Citizen BASIC Interpreter - MaRCo

Programming Manual for Citizen BASIC Interpreter - MaRCo

Programming Manual for Citizen BASIC Interpreter - MaRCo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Citizen</strong> <strong>BASIC</strong> <strong>Interpreter</strong><br />

Done=1<br />

ELSE<br />

Done=0<br />

ENDIF<br />

2.3.6 Control Loop<br />

Use of a loop repeatedly executes a series of statements to stop execution using<br />

control conditions or control variables. <strong>BASIC</strong> includes four types of control<br />

loops: REPEAT statement, WHILE statement, DO statement and FOR statement.<br />

Use of the EXIT procedure controls the flow of the REPEAT statement, WHILE statement,<br />

DO statement or FOR statement. EXIT ends execution of a statement including them.<br />

2.3.7 REPEAT Statement<br />

The following shows the syntax of the REPEAT statement:<br />

REPEAT<br />

{statement}<br />

UNTIL <strong>for</strong>mula<br />

The <strong>for</strong>mula returns a logic value. The REPEAT statement executes a series of<br />

statements constructing it to test the <strong>for</strong>mula every time repetition ends. When<br />

the <strong>for</strong>mula returns true, the REPEAT statement ends. Since the <strong>for</strong>mula is not<br />

assessed until the first execution is completed, a series of statements will always<br />

be executed at least once.<br />

An example of the REPEAT statement includes:<br />

REPEAT<br />

K=I MOD J<br />

I=J<br />

J=K<br />

UNTILJ=0<br />

REPEAT<br />

PRINT"Enter a value(0..9):";<br />

INPUT I<br />

UNTIL(I>=0)AND(I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!