TOPLEVEL stops execution of a procedure and returns Logo to toplevel, the command mode. TOPLEVEL is the primitive to use in a procedure to perform the same function that Control-G does from the keyboard.
Note that TOPLEVEL is different from STOP in that control is not returned to any calling procedure.
The procedure below can be used as a subprocedure of a game program. If the player wants to end the game, the procedure returns to toplevel.
- PR [DO YOU WISH TO CONTINUE?]
- PR [PLEASE TYPE YES OR NO]
- MAKE "ANSWER READLIST
- IF :ANSWER = [YES] THEN GAME
- IF :ANSWER = [NO] THEN PR[THAT'S ALL FOR THIS GAME.] TOPLEVEL ENDALL