Conditional Commands - until, while

The key to understanding the syntax of MSW Logo commands is that each command must be on only ONE line. The compiler cannot 'link' together a series of commands spread over several lines.

In Pascal, for example, the "repeat/until" loop looks something like this:

repeat
    <action1>
    <action2>
    ....
    ....
until <condition>

In MSW Logo, all instructions are on the SAME LINE in the form:

repeat.until <action1, action2 ....><condition>

NOTE: Two points - Firstly this is NOT the way to use the "repeat" command in MSW Logo and secondly, square brackets are used. If the command was correct it would be in the form:
repeat.until [action1, action2, ...][condition]

Using until  and while

General form:
until [condition][action]
while [condition][action]

make "count 1
until [:count > 10][print :count  make "count  :count + 1]
  .... produces: 1 2 3 4 5 6 7 8 9 10

make "count 1
while [:count < 10][print :count  make "count  :count + 1]
  .... produces: 1 2 3 4 5 6 7 8 9

NOTE: There can be many 'actions' in the square brackets including procedures.

<- Back -Menu- Next ->