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.

$LISTNEXT$LISTNEXTRetrieves elements sequentially from a list.$LISTNEXT(list,ptr,value)ParameterslistptrvalueAny expression that evaluates to a list.A pointer to the next element in the list. Initialized to 0 to point to the beginningof a list.The data value of the element, returned as a string.Description$LISTNEXT sequentially returns elements in a list. You initialize ptr to 0 prior to the firstinvocation of $LISTNEXT. Each invocation of $LISTNEXT increments ptr and returns thelist element value to value. $LISTNEXT returns 1, indicating that a list element has beensuccessfully retrieved.When $LISTNEXT reaches the end of the list, it returns 0, resets ptr to 0, and leaves valueunchanged from the previous invocation. Because ptr has been reset to 0, the next invocationof $LISTNEXT would start at the beginning of the list.ExamplesThe following example sequentially returns all of the elements in the list:SET list=$LISTBUILD("Red","Blue","Green")SET ptr=0,count=0WHILE $LISTNEXT(list,ptr,value) {SET count=count+1WRITE !,value }WRITE !,"End of list: ",count," elements found"QUITNotesError for Invalid ListsIf list is not a valid list, you may receive a error.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 257

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

Saved successfully!

Ooh no, something went wrong!