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> FunctionsDescription$LISTDATA checks for data in the requested element in a list and returns a boolean value.$LISTDATA returns a value of 1 if the element indicated by the position parameter is in thelist and has a data value. $LISTDATA returns a value of a 0 if the element is not in the listor does not have a data value.ParameterslistA list is an encoded string containing multiple elements. A list must have been created using$LISTBUILD or $LISTFROMSTRING, or extracted from another list using $LIST.positionIf you omit the position parameter, $LISTDATA evaluates the first element. If the value ofthe position parameter is -1, it is equivalent to specifying the final element of the list. If thevalue of the position parameter refers to a nonexistent list member, then invoking the$LISTDATA function returns a 0.ExamplesThe following examples show the results of the various values of the position parameter.All of the following $LISTDATA statements return a value of 0:KILL YSET X=$LISTBUILD("Red",,Y,"","Green")WRITE !,$LISTDATA(X,2) ; second element is undefinedWRITE !,$LISTDATA(X,3) ; third element is killed variableWRITE !,$LISTDATA("") ; null stringWRITE !,$LISTDATA(X,0) ; the 0th positionWRITE !,$LISTDATA(X,6) ; 6th position in 5-element listThe following $LISTDATA statements return a value of 1 for the same five-element list:SET X=$LISTBUILD("Red",,Y,"","Green")WRITE !,$LISTDATA(X) ; first position (by default)WRITE !,$LISTDATA(X,1) ; first position specifiedWRITE !,$LISTDATA(X,4) ; fourth position value=null stringWRITE !,$LISTDATA(X,5) ; fifth positionWRITE !,$LISTDATA(X,-1) ; last (5th) positionNotesInvalid Parameter ValuesIf the expression in the list parameter does not evaluate to a valid list, a error occurs.248 <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!