**NewBie's Corner Session 6 If and Kill commands** Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material. Click on the Caché Cube in your system tray and select Terminal to try out the commands. As in other computer programming languages, the If command is the primary decision makes. **If command with numeric operands**
Set X=12
If X=12 Set X=13
Write X
13
**If command with alphanumeric operands**
Set X="<stockticker w:st="on">ABC</stockticker>"
If X="<stockticker w:st="on">ABC</stockticker>" Set X="XYZ"
Write X
XYZ
Whenever alphanumeric data is being referenced, quotation marks are required. **Kill command** Thus far, we have learned how to set a variable to a value with the Set command; display that value using the Write command; and using the If command, conditionally set a variable to another value. Now we will completely delete the variable and its value.
Set X="<stockticker w:st="on">ABC</stockticker>"
Kill X
Write X
<UNDEFINED>
In this example the Kill command completely deletes the variable and any value that it contains. After killing the variable X, any attempt to access X results in an <UNDEFINED> error. Notice that the Kill command not only removes the value a variable holds, but completely removes or deletes the variable as well. **Kill all variables** The Kill command used with no parameters or variables removes all variables defined thus far.
Set X=12,Y=13,Z=14         ;set variables
Write                                     ;write all variables
X=12
Y=13
Z=14
Kill                                          ;kill all variables
Write                                     ;write all variables, but none exist
<> 
This shows the Kill command with no variables, a Write command with no variable produces no output because no variables exist. **Kill all variables except Y and Z** **The Kill command used with adjoining parenthesis, save variable(s)**
Set X=12,Y=13,Z=14         ;set variables
Kill (Y,Z)                                ;kill all variables except Y and Z
Write                                     ;write all variables
Y=13
Z=14
This shows the Kill command kill except Y and Z I suggest you spend some time on the Terminal trying some of these combinations. They are not always as obvious as you think. --Mike Kadow [_PaulMikeKadow@gmail.com_](mailto:PaulMikeKadow@gmail.com) If you have a comment, please respond through the InterSystems Developer Community, don't send me private email. Unless of course you wish to address me only. See [NewBie Index](/node/411951) for an index of all NewBie Corner posts