Kill

The KILL command deletes local or global variables and their descendant nodes.

The format of the KILL command is:

K[ILL][:tvexpr] [glvn | (glvn[,...]) | *lname | *lvn ]
[Caution] Caution

Use KILL with caution because it can have a major impact on the process environment (local variables) or shared data (global variables).

Examples of KILL

Example:

GTM>Kill  Set a=0,a(1)=1,a(1,1)="under" KILL a(1) ZWR
a=0
GTM>

This uses an argumentless KILL to get a "fresh start" by deleting all existing local variables. After SETting a, a(1), and a(1,1), the KILL deletes a(1) and its descendants. The ZWRITE shows only a remaining.

Example:

GTM>Kill (a,b),^AB(a,b)

The first argument (an exclusive KILL) specifies to KILL all local variables except a and b. The second argument deletes ^AB(a,b) and any descendants of that global variable node.

Example:

    kill *
    write !,"gtm_stdxkill=",+$ztrnlnm("gtm_stdxkill"),!
    set (A,B,C,E)="input"
    do X(.A,.B)
    zwrite
    write !,"____________",!
    set (A,B,C,E)="input"
    do Y(.A,.B)
    zwrite
    write !,"____________",!
    set (A,B,C,E)="base"
    set *C=A,*D=B
    kill (C,D)
    zwrite
    quit
X(C,D)    set (C,D)="output"
    kill (C,D)
    quit
Y(C,D)    set (C,D)="output"
    kill (A,C,D)
    quit

Produces the following output:

gtm_stdxkill=0
A="output"
B="output"
C="input"
____________
A="output"
B="output"
C="input"
____________
A="base" ;*
B="base" ;*
*C=A
*D=B