$LISTVALID
Synopsis
$LISTVALID(exp) $LV(exp)
Parameters
exp | An expression. |
Description
$LISTVALID determines whether exp is a Caché list, and returns a Boolean value: If exp is a list, $LISTVALID returns 1; if exp is not a list, $LISTVALID returns 0.
A list can be created using $LISTBUILD or $LISTFROMSTRING, or extracted from another list using $LIST. A list containing the empty string ("") as its sole element is a valid list. The empty string ("") by itself is also considered a valid list.
Examples
The following examples all return 1, indicating a valid list:
w = $LISTBUILD("Red","Blue","Green") x = $LISTBUILD("Red") y = $LISTBUILD(365) z = $LISTBUILD("") CRT $LISTVALID(w) CRT $LISTVALID(x) CRT $LISTVALID(y) CRT $LISTVALID(z)
The following examples all return 0. Numbers and strings (with the exception of the null string) are not valid lists:
x = "Red" y = 44 CRT $LISTVALID(x) CRT $LISTVALID(y)
The following examples all return 1. Concatenated, nested, and omitted value lists are all valid lists:
w=$LISTBUILD("Apple","Pear") x=$LISTBUILD("Walnut","Pecan") y=$LISTBUILD("Apple","Pear",$LISTBUILD("Walnut","Pecan")) z=$LISTBUILD("Apple","Pear",,"Pecan") CRT $LISTVALID(w:x) ! concatenated CRT $LISTVALID(y) ! nested CRT $LISTVALID(z) ! omitted element
The following examples all return 1. $LISTVALID considers all of the following “empty” lists as valid lists:
CRT $LISTVALID("") CRT $LISTVALID($LB()) CRT $LISTVALID($LB(NULL)) CRT $LISTVALID($LB("")) CRT $LISTVALID($LB(CHAR(0))) CRT $LISTVALID($LB(,))
See Also
$LIST function
$LISTBUILD function
$LISTDATA function
$LISTFIND function
$LISTFROMSTRING function
$LISTGET function
$LISTLENGTH function
$LISTNEXT function
$LISTSAME function
$LISTTOSTRING function