Erases a line or range of lines from the current routine.
||Optional A postconditional expression.
||Optional The single line, or first line in a range of lines to be removed. If you omit lineref1, ZREMOVE deletes the entire current routine.
||Optional The last in a range of lines to be removed.
The ZREMOVE command erases routine lines from the current routine. ZREMOVE has two forms:
Without an argument
You can only use the ZREMOVE command when you enter it in the Terminal or when you call it using an XECUTE command. It should not be coded into the body of a routine because its operation would effect the execution of that routine.
Only the local copy of the routine is affected, not the routine as stored on disk. To store the modified code, you must use the ZSAVE command to save the routine.
Without an Argument
ZREMOVE without an argument erases the entire current routine. The following Terminal session shows this operation:
ZREMOVE with arguments erases code lines in the current routine. ZREMOVE lineref1 erases the specified line. ZREMOVE lineref1:lineref2 erases the range for lines starting with the first line reference and ending with the second line reference, inclusive.
The following Terminal session shows this operation. This example uses a dummy routine (^myroutine) in which each line sets a variable to a string naming that line:
SET x="this is line 8"
SET x="this is line 9"
An optional postconditional expression. InterSystems IRIS executes the command if the postconditional expression is true (evaluates to a nonzero numeric value). InterSystems IRIS does not execute the command if the postconditional expression is false (evaluates to zero). For further details, refer to Command Postconditional Expressions
in Using ObjectScript
The line to be removed, or the first in a range of lines to be removed. It can take any of the following formats:
||Specifies a line number within the routine. A positive integer, counting from 1.
||Specifies a label within the routine. ZREMOVE erases only the label line itself. This includes any code that follows the label on that line.
||Specifies a label and the number of line to offset within the labeled section, counting the label line as line 1.
A label may be longer than 31 characters, but must be unique within the first 31 characters. ZREMOVE matches only the first 31 characters of a specified label. Label names are case-sensitive, and may contain Unicode characters.
You can use lineref1 to specify a single line of code to remove. You specify the code line either as an offset from the beginning of the routine (+lineref1) or as an offset from a specified label (module2+lineref1).
ZREMOVE +7: removes the 7th line counting from the beginning of the routine.
ZREMOVE +0: performs no operation, generates no error.
ZREMOVE +999: if 999 is greater than the number of lines in the routine, performs no operation, generates no error.
ZREMOVE Test1: removes the label line Test1.
ZREMOVE Test1+0: removes the label line Test1.
ZREMOVE Test1+1: removes the first line following label line Test1.
ZREMOVE Test1+999: removes the 999th line following label line Test1. This line may be in another labeled module. If 999 is greater than the number of lines from label Test1 to the end of the routine, performs no operation, generates no error.
are counted as code lines in a line offset. Whitespace
lines are not counted as code lines in line offset. Comments
are not counted as code lines in a line offset, with one exception. A single-line comment delimited by ;; is counted as a code line for the purposes of line offset.
The last line in a range of lines to be removed. Specify lineref2 in any of the formats used for lineref1. The colon prefix (:) is mandatory.
You specify a range of lines as +lineref1:+lineref2. ZREMOVE removes the range of lines, inclusive of lineref1 and lineref2. If lineref1 and lineref2 refer to the same line, ZREMOVE removes a that single line.
If lineref2 appears earlier in the routine code than lineref1, no operation is performed and no error is generated. For example: ZREMOVE +7:+2, ZREMOVE Test1+1:Test1, ZREMOVE Test2:Test1 would perform no operation.
This command erases the fourth line within the current routine.
This command erases the sixth line after the label Test1.
This command erases lines three through ten, inclusive, within the current routine.
This command erases the label line Test1 through the line that immediately follows it, within the current routine.
This command erases all of the line from label Test1 through label Test2, inclusive of both labels, within the current routine.
Content Date/Time: 2019-08-16 05:50:13