Skip to Content
Learn Red ? Fundamentals of Red
book

Learn Red ? Fundamentals of Red

by Ivo Balbaert
May 2018
Beginner content levelBeginner
252 pages
6h 19m
English
Packt Publishing
Content preview from Learn Red ? Fundamentals of Red

Stopping a program – halt or quit

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.

With the /return refinement, you can signal a return status to the operating system by phrasing it as quit/return 5. You could ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How I Built a Personal Board of Directors With GenAI

How I Built a Personal Board of Directors With GenAI

Vipin Gupta
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally
Why AI Demands a New Breed of Leaders

Why AI Demands a New Breed of Leaders

Faisal Hoque, Thomas Davenport, Erik Nelson

Publisher Resources

ISBN: 9781789130706Supplemental Content