11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Caché</strong> <strong>ObjectScript</strong> CommandsThe nodes can be in the same or different arrays.You may delete a specified local or global array node by using the ZKILL command. UnlikeKILL, ZKILL does not delete all nodes subordinate to the specified node.Effects of KILL with Parameter PassingWith parameter passing, values are passed to a user-defined function or to a subroutine calledwith the DO command. The values to be passed to the user-defined function or subroutineare supplied in a comma separated list called the actual parameter list. Each value suppliedis mapped, by position, into a corresponding variable in the formal parameter list defined forthe user-defined function or subroutine.Depending on how the actual parameter list is specified, parameter passing can occur in eitherof two ways: by value or by reference. For more information on these two types of parameterpassing, see DO with Parameter Passing.Killing a variable in the formal parameter list has different results depending on whetherpassing by value or passing by reference is in effect.If you are using passing by value, killing a variable in the formal list has no effect outsidethe context of the invoked function or subroutine. This is because <strong>Caché</strong> automatically savesthe current value of the corresponding actual variable when the function or subroutine isinvoked. It then automatically restores the saved value on exit from the function or subroutine.If you are passing by reference, killing a variable in the formal list also kills the correspondingactual variable. When the function or subroutine terminates, the actual variable will no longerexist. In the following example, the KILL in Subrt1 deletes both the formal variable x andthe actual variable a.TestSET a=17WRITE !,"Before: a=",aDO Subrt1(a)WRITE !,"After: a=",aQUITSubrt1(x)WRITE !,"x=",xKILL xQUITAs a general rule, you should not KILL variables specified in a formal parameter list. When<strong>Caché</strong> encounters a function or subroutine that uses parameter passing (whether by value orby reference), it implicitly executes a NEW command for each variable in the formal list.When it exits from the function or subroutine, it implicitly executes a KILL command foreach variable in the formal list. In the case of a formal variable that uses passing by reference,78 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!