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> CommandsNotesKILL and ObjectsObject variables (OREFs) automatically maintain a reference count — the number of itemscurrently referring to an object. Whenever you SET a variable or object property to refer toan object, <strong>Caché</strong> increments the object's reference count. When you KILL a variable, <strong>Caché</strong>decrements the corresponding object reference count. When this reference count goes to 0,the object is automatically destroyed; that is, <strong>Caché</strong> removes it from memory. The objectreference count is also decremented when a variable is SET to a new value, or when thevariable goes out of scope.In the case of a persistent object, call the %Save() method before removing the object frommemory if you wish to preserve changes to the object. The %Delete() method deletes thestored version of a <strong>Caché</strong> object; it does not remove the in-memory version of that object.Prior to <strong>Caché</strong> version 5.0, the %Close() method could be used to remove objects frommemory. With <strong>Caché</strong> version 5.0 and subsequent, the %Close() method performs no operationand always returns successful completion. Do not use %Close() when writing new code.Inclusive KILLAn inclusive KILL deletes only those variables explicitly named. The list can include localvariables, process-private globals, and globals—either subscripted or unsubscripted. Theinclusive KILL is the only way to delete global variables.Exclusive KILLAn exclusive KILL deletes all local variables except those that you explicitly name. Listednames are separated by commas. The enclosing parentheses are required.The exception list can contain only local unsubscripted variable names. For example, if youhave a local variable array named fruitbasket, which has several subscript nodes, you canpreserve the entire local variable array by specifying KILL (fruitbasket); you cannot useexclusive KILL to selectively preserve individual subscript nodes. An exclusive kill listcannot specify a process-private global, a global, or a special variable; attempting to do soresults in a error. Local variables not named in the exception list are deleted;subsequent references to such variables generate an error. The exclusiveKILL has no effect on process-private globals, globals, and special variables. However, itdoes delete local variables created by system objects.Using KILL with Arrays• To delete a local variable array, use any form of KILL.76 <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!