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> Functionseven when variable is defined. If a global variable, it can contain an extended global reference.If a subscripted global variable, it can be specified using a naked global reference. If present,default resets the naked indicator, affecting future naked global references, as describedbelow.ExamplesIn the following example, the variable test is defined and the variable xtest is undefined. (TheZWRITE command is used because it explicitly returns a null string value.)KILL xtestSET test="banana"SET tdef=$GET(test),tundef=$GET(xtest)ZWRITE tdef ; $GET returned value of testZWRITE tundef ; $GET returned null string for xtestWRITE !,$GET(xtest,"none"); $GET returns default of "none" for undefined variableNotes$GET Compared to $DATA$GET provides an alternative to $DATA tests for both undefined variables ($DATA=0) andarray nodes that are downward pointers without data ($DATA=10). If the variable is eitherundefined or a pointer array node without data, $GET returns a null string ("") without anundefined error. For example, you can recode the following lines:as:IF $DATA(^client(i))=10 {WRITE !!,"Name: No Data"GOTO Level1+3}IF $GET(^client(i))="" {WRITE !!,"Name: No Data"GOTO Level1+3}Note that $DATA tests are more specific than $GET tests because they allow you to distinguishbetween undefined elements and elements that are downward pointers only. Forexample, the lines:IF $DATA(^client(i))=0 { QUIT }ELSEIF $DATA(^client(i))=10 {WRITE !!,"Name: No Data"GOTO Level1+3}could not be recoded as:218 <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!