REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: quit

quit  /return  value  /now

Stops evaluation and exits the interpreter.

Refinements:

/return - Returns a value (to prior script or command shell)

value - Note: use integers for command shell

/now - Quit immediately

See also:

halt   exit   q  

Description

You can call quit to exit (terminate) your program at any point.

time: 10:00
if time > 12:00 [
    print "time for lunch"
    quit
]

Without refinements, quit is a non-forceful exception (it will throw a quit exception.) This behavior allows a parent program to stop the termination.

To force an immediate quit (no exception), use the /now refinement:

if bad-data [quit/now]

You can also return an integer! quit code to the operating system (shell) by using the return refinement:

quit/return 40

Note that not all operating systems environments may support this quit code.

Rarely used

Most programs do not require quit, and it can be problematic if your code is started by another REBOL program. Normally, when your program reaches the end, it will quit by itself. (If you want to prevent that behavior, use the -h command line option, or call halt at the end of your code.)


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin