May 2018
Beginner
252 pages
6h 19m
English
How do you stop a program when a certain condition is met? For example, in our guessing program, we want to stop running the script when the user enters the letter S. Here is the solution—just use quit in the console, as shown in the following code:
answer: ask "Type a number (from 1 till 99) or stop(S): "if answer = "S" [ print "OK, you want to stop." quit]print "This line is not executed when S is entered"
This could be written as an either statement, but I find it more readable in this format.
The quit word can also be used to exit from a program when there is an error condition.