Caché ObjectScript Reference
ZPRINT
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Displays lines of code from the current routine on the current device.
Synopsis
ZPRINT:pc lineref1:lineref2
ZP:pc lineref1:lineref2
Arguments
pc Optional — A postconditional expression.
lineref1 Optional — The line to be displayed, or the first line in a range of lines to be displayed. Can be a label name, a numeric offset (+n) or a label name and a numeric offset. If omitted, the entire current routine is displayed.
:lineref2 Optional — The last line in a range of lines to be displayed. To define a range, lineref1 must be specified.
Description
The ZPRINT command displays lines of code from the currently loaded routine. The output is sent to the current device. You establish the current device with the USE command. For the name of the current routine, access the $ZNAME special variable. For the device ID of the current device, access the $IO special variable.
Note:
The ZPRINT and PRINT commands are functionally identical.
The displayed lines include all labels, comments, and whitespace, with the exception that entirely blanks lines are neither displayed nor counted. For this reason, ZPRINT displays and counts the following multi-line comment as two lines, not three:
   /* This comment includes

      a blank line */ 
ZPRINT has two forms:
ZPRINT without arguments displays all the lines of code in the currently loaded routine.
ZPRINT with arguments displays the specified lines of code. ZPRINT lineref1 displays the line specified by lineref1. ZPRINT lineref1:lineref2 displays the range of lines starting with lineref1 and ending with lineref2 (inclusive).
The lineref arguments count lines and line offsets using the object code version of the routine. After modifying a routine, you must re-compile the routine for ZPRINT to correctly count lines and line offsets that correspond to the source version.
You can use the $TEXT function to return a single line of code.
Arguments
pc
An optional postconditional expression. Caché executes the ZPRINT command if the postconditional expression is true (evaluates to a nonzero numeric value). Caché does not execute the command if the postconditional expression is false (evaluates to zero). For further details, refer to Command Postconditional Expressions in Using Caché ObjectScript.
lineref1
The line to be printed or the first in a range of lines to be displayed or printed. Can be specified in either of the following syntactical forms:
A label may be longer than 31 characters, but must be unique within the first 31 characters. ZPRINT matches only the first 31 characters of a specified label. Label names are case-sensitive, and may contain Unicode characters.
lineref2
The last line in a range of lines to be displayed. Specify in the same way as lineref1.lineref1 must be specified to specify lineref2. lineref1 and lineref2 are separated by a colon (:) character. No whitespace may appear between the colon and lineref2.
If lineref2 is earlier in the line sequence than lineref1, ZPRINT ignores lineref2 and displays the single line of code specified by lineref1.
Examples
Given the following lines of code:
AviationLetters
Abc
  WRITE "A is Abel",!
  WRITE "B is Baker",!
  WRITE "C is Charlie",!
Def WRITE "D is Delta",!
  WRITE "E is Epsilon",!
  /* Not sure about E */
  WRITE "F is Foxtrot",!
ZPRINT with no lineref arguments displays all nine lines, including the comment line.
ZPRINT +0 displays the empty string.
ZPRINT +1 displays the AviationLetters label.
ZPRINT +8 displays the /* Not sure about E */ comment line.
ZPRINT +10 displays the empty string.
ZPRINT Def or ZPRINT Def+0 display the Def WRITE "D is Delta",! line. This is a label line that also includes executable code.
ZPRINT Def+1 displays the WRITE "E is Epsilon",! line.
Range Examples
ZPRINT +0:+3 displays the empty string.
ZPRINT +1:+3 displays the first three lines.
ZPRINT +3:+3 displays the third line.
ZPRINT +3:+1 displays the third line; lineref2 is ignored.
ZPRINT +3:Abc+1 displays the third line. Both lineref1 and lineref2 are specifying the same line.
ZPRINT +3:abc+1 displays from the third line to the end of the routine. Line labels are case-sensitive, so the range endpoint was not found.
ZPRINT Abc+1:+4 displays lines 3 and 4.
ZPRINT Abc+1:Abc+2 displays lines 3 and 4.
ZPRINT Abc:Def displays lines 2, 3, 4, 5, and 6.
ZPRINT Abc+1:Def displays lines 3, 4, 5, and 6.
ZPRINT Def:Abc displays the Def WRITE "D is Delta",! line. Because lineref2 is earlier in the code, it is ignored.
See Also