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> Functions• greater than position, an encoded string containing a list of elements is returned.• equal to position, an encoded string containing the one element is returned.• less than position, the null string ("") is returned.• greater than the number of elements in list, it is equivalent to specifying the final elementin the list.• negative one (–1), it is equivalent to specifying the final element in the list.When specifying end, you can specify a position value of zero (0). In this case, 0 is equivalentto 1.ExamplesThe following two WRITE statements both return “RED”, the first element in the list. Thefirst writes the first element by default, the second writes the first element because the positionparameter is set to 1:WRITE !,$LIST($LISTBUILD("RED","BLUE","GREEN"))WRITE !,$LIST($LISTBUILD("RED","BLUE","GREEN"),1)The following example returns “Blue”, the second element in the list:SET X=$LISTBUILD("Red","Blue","Green")WRITE $LIST(X,2)The following example returns “Red Blue”, a two-element list string beginning with the firstelement and ending with the second element in the list. ZZDUMP is used rather than WRITE,because a list string contains special (non-printing) encoding characters:SET X=$LISTBUILD("Red ","Blue ","Green ")ZZDUMP $LIST(X,1,2)The following example returns “Brown Black”, a two-element list string that begins with thethird element and ends with the last element in the list:SET X=$LISTBUILD("Green ","White ","Brown ","Black ")SET LIST2=$LIST(X,3,-1)ZZDUMP LIST2NotesInvalid Parameter ValuesIf the expression in the list parameter does not evaluate to a valid list, a error occurs.SET x=$CHAR(0,0,0,1,16,27,134,240)SET a=$LIST(x,2) // generates a error242 <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!