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.

$ZUTIL(18)012Issues the error for any undefined variable.Returns a null string for a reference to an undefined variable with subscripts, andissues the error for undefined variables without subscripts.Returns a null string (instead of issuing an error) for any undefinedvariable.Integers larger than 2 or smaller than –1 are ignored as no-ops. A value of –1 sets $ZUTIL(18)to 2.NotesThe $DATA function tests if a specified variable is defined. It returns 0 if the variable isundefined.The $GET function returns a default value if a specified variable is undefined. The basicform of $GET returns a null string if the specified variable is undefined.The $ZUTIL(18) function defines handling behavior for all undefined variables: local variables,process-private globals, and globals. Setting $ZUTIL(18) has no effect on $DATA or$GET.You can use the ZWRITE command to display defined variables that have a null string value;ZWRITE does not display undefined variables that return a null string.ExamplesIn the following example, <strong>Caché</strong> by default issues an error when encounteringan undefined variable. $ZUTIL(18) overrides that default for the local process.WRITE !,"system:",$ZUTIL(69,0)," local:",$ZUTIL(18)SET x=$ZUTIL(18,2)WRITE !,"system:",$ZUTIL(69,0)," local:",$ZUTIL(18)NEW fredIF fred="" {WRITE !,"null string for undefined variable" }ELSE {WRITE !,$GET(fred,"undefined variable not null") }In the following example, $ZUTIL(18,1) sets undefined variable handling to return a nullstring for defined subscripts (such as ^||X(A,B,C)) of an undefined process-private global^||X. The ZWRITE command is used to show variables set to a null string.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 577

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

Saved successfully!

Ooh no, something went wrong!