Caché Basic Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   

Indicates whether an element is present in the list and has a value.
list An expression that evaluates to a valid list. A Caché list must be created using ListBuild or ListFromString, or extracted from another list using List.
position An integer specifying a position in list (counting from 1).
The ListExists function returns a value of 1 if the element at the indicated position in the list exists and has a data value. Otherwise ListExists returns zero.
The following example demonstrates the ListExists function. It defines a six-element list, in which the third and fourth elements do not have a defined value:
Erase Y      ' Y is now undefined
myList = ListBuild("Red","Blue",,Y,"Yellow","")
Println ListExists(myList,0)  ' 0: positions are numbered from 1
Println ListExists(myList,1)  ' 1: "Red"
Println ListExists(myList,2)  ' 1: "Blue"
Println ListExists(myList,3)  ' 0: missing element
Println ListExists(myList,4)  ' 0: undefined element
Println ListExists(myList,5)  ' 1: "Yellow"
Println ListExists(myList,6)  ' 1: empty string OK
Println ListExists(myList,7)  ' 0: beyond end of list
Println ListExists(myList,-1) ' 1: last element in list
See Also

Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA