Glich - v0.3.0 Manual
exit Statement
Development v0.3.0 Manual Glich Script Statements exit Statement

Statement: exit

The exit statement simply stops execution of the script.

Example Script
write "So far so good." nl; exit; write "We never get here!" nl;
Output:-
So far so good.

Usage in Functions and Commands

If the exit statement is used in a function or command, then it ends the function or command and the script continues running from the calling point.

Example Script
function must_be_positive(x) { if x <= 0 { result = @error("Value must be positive."); exit; }; result = x; }; write @must_be_positive(5) nl; write @must_be_positive(-3) nl;
Output:-
5 Value must be positive.

Usage in Do Loops

If the exit statement is used in a do loop, then it ends the loop and the script continues running from the point after the loop.

Example Script
do i in 1..10 { write i,; if i = 5 { exit; }; }; write "Done" nl;
Output:-
1, 2, 3, 4, 5, Done
Development v0.3.0 Manual Glich Script Statements exit Statement

Managed by WebPageLayout Validated by HTML Validator (based on Tidy)

9th March 2023