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> FunctionsSET x=$LISTBUILD("Apple","Pear","Walnut","Pecan")SET y=$LISTBUILD("Apple","Pear",$LISTBUILD("Walnut","Pecan"))SET z=$LISTBUILD("Apple","Pear","Walnut","Pecan","")WRITE !,$LISTSAME(x,y)," nested list"WRITE !,$LISTSAME(x,z)," null string is list item"The following example returns 1, because the lists are considered identical:SET x=$LISTBUILD("Apple","Pear","Walnut","Pecan")SET y=$LISTBUILD("Apple","Pear")_$LISTBUILD("Walnut","Pecan")WRITE !,$LISTSAME(x,y)," concatenate lists"Null String and Null ListA list containing the null string (an empty string) as its sole element is a valid list. The nullstring by itself is also considered a valid list. However these two (a null string and a null list)are not considered identical, as shown in the following example:WRITE !,$LISTSAME($LISTBUILD(""),$LISTBUILD(""))," null lists"WRITE !,$LISTSAME("","")," null strings"WRITE !,$LISTSAME($LISTBUILD(""),"")," null list and null string"Normally, a string is not a valid $LISTSAME argument, and $LISTSAME issues a error. However, the following $LISTSAME comparisons complete successfully and return0. The null string and the string “abc” are compared and found not to be identical. These nullstring comparisons do not issue a error:WRITE !,$LISTSAME("","abc")WRITE !,$LISTSAME("abc","")The following $LISTSAME comparisons do issue a error, because a list (even anull list) cannot be compared with a string:SET x = $LISTBUILD("")WRITE !,$LISTSAME("abc",x)WRITE !,$LISTSAME(x,"abc")See Also• $LIST function• $LISTBUILD function• $LISTDATA function• $LISTFIND function• $LISTFROMSTRING function• $LISTGET function• $LISTLENGTH function260 <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!