11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

$LIST• $LIST(list) returns the first element string in the list.• $LIST(list,position) returns the element indicated by the specified position. The positionparameter must evaluate to an integer.• $LIST(list,position,end) returns a “sublist” (an encoded list string) containing the elementsof the list from the specified start position through the specified end position.You can also use $LISTNEXT to sequentially return elements from a list.ParameterslistAn encoded list string containing one or more elements. Lists can be created using$LISTBUILD or $LISTFROMSTRING, or extracted from another list by using the $LISTfunction. The following are valid list arguments:SET myList = $LISTBUILD("Red", "Blue", "Green", "Yellow")WRITE !,$LIST(myList,2) ; prints BlueSET subList = $LIST(myList,2,4)WRITE !,$LIST(subList,2) ; prints GreenIn the following example, subList is not a valid list argument, because it is a single elementreturned as an ordinary string, not an encoded list string:SET myList = $LISTBUILD("Red", "Blue", "Green", "Yellow")SET subList = $LIST(myList,2)WRITE $LIST(subList,1)positionThe position of a list element to return. List elements are counted from 1. If position isomitted, the first element is returned. If the value of position is 0 or greater than the numberof elements in the list, <strong>Caché</strong> issues a error. If the value of position isnegative one (–1), $LIST returns the final element in the list.If the end parameter is specified, position specifies the first element in a range of elements.Even when only one element is returned (when position and end are the same number) thisvalue is returned as an encoded list string. Thus, $LIST(x,2) is not identical to $LIST(x,2,2).endThe position of the last element in a range of elements. You must specify position to specifyend. When end is specified, the value returned is an encoded list string. Because of thisencoding, such strings should only be processed by other $LIST functions.If the value of end is:<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 241

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

Saved successfully!

Ooh no, something went wrong!