FANDOM


This process of sequential operation is called program flow. Once Logo begins to execute a procedure, the control of the computer passes from the keyboard to the procedure. Logo provides commands that allow you to control the flow of the computer's operation from within Logo procedures. You can use IF and related primitive to test conditions in the Logo environment and pass control to one procedure or another depending on the condition being met. You can let the user determine how the program is to proceed by considering input from the keyboard to determine which procedure to call next. Your Logo program can examine information in disk files and operate in various manners according to what is encountered. The ability to control he flow and timing of your computer is a powerful aspect of Logo.

The following primitives and system names allow you to control the flow of your procedures:

AND IFTRUE THEN
CATCH LABEL THROW
CONTINUE NOT TOPLEVEL
ELSE OR TRACE
ERROR PAUSE TRACE.LEVEL
FALSE REPEAT TRON
FOR RUN TROFF
GO SINGLE.STEP TRUE
IF STOP WAIT
IFFALSE TEST WHILE

The recursive SQUARE procedure above continued operation endlessly until it was interrupted with certain combinations of keys that tell the computer to stop whatever it was doing (Control-G or the Stop button). It might be useful to have the procedure stop and return control to the user after it has drawn the largest square that will fit on the screen. The following example shows a SQUARE procedure that will stop after it has drawn a square of size 200:

? TO SQUARE :SIDE

> IF :SIDE > 200 THEN STOP

> REPEAT 4 [FD :SIDE RT 90]

> END

SQUARE defined

? SQUARE 10

Pc logo xp 2

This is the result of the procedure.

SQUARE draws square as it did before, but each time it calls itself it examines the value of :SIDE to see if it is greater than 200. When the value of :SIDE exceed 200 the procedures stops and returns control to the user, as indicated by the question mark (?) prompt indicating that Logo is waiting for further instruction.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.