This page is meant to give a summary of how to use halt statements in ZPL programs. If you find inconsistencies between this document and your use of ZPL, or bugs in the halt statement, please let us know at email@example.com.
The halt statement is used to exit out of a ZPL program in the case of abnormal conditions. It has two modes of use: As a simple statement:
if (x = 0) then halt; end;
and as a statement with output that should be printed (in which case it works similarly to a writeln() statement).
if (x < 0) then halt("Unexpected value for x: ","%d":x); end;
In the first case, if x was 0, the flow of control would enter the conditional and the program would exit, printing out a message like:
halt at line 22 reached
In the second case, if x was negative, the halt would again be reached and the following would be printed to the screen:
Unexpected value for x: -10 halt at line 34 reached
When running ZPL programs with the -q (quiet) flag, the "halt at line x reached" message is not be generated when halts are reached.
If you have further questions about halts in ZPL, please don't hesitate to contact us at firstname.lastname@example.org.