Skip to main content

This version of the product is no longer supported, and this documentation is no longer updated regularly. See the latest version of this content.Opens in a new tab

$LISTVALID

Determines if an expression is a list.

Synopsis

$LISTVALID(exp)
$LV(exp)

Parameter

exp Any valid expression.

Description

$LISTVALID determines whether exp is a 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:

   SET w = $LISTBUILD("Red","Blue","Green")
   SET x = $LISTBUILD("Red")
   SET y = $LISTBUILD(365)
   SET z = $LISTBUILD("")
   WRITE !,$LISTVALID(w)
   WRITE !,$LISTVALID(x)
   WRITE !,$LISTVALID(y)
   WRITE !,$LISTVALID(z)

The following examples all return 0. Numbers and strings (with the exception of the null string) are not valid lists:

   SET x = "Red"
   SET y = 44
   WRITE !,$LISTVALID(x)
   WRITE !,$LISTVALID(y)

The following examples all return 1. Concatenated, nested, and omitted value lists are all valid lists:

   SET w=$LISTBUILD("Apple","Pear")
   SET x=$LISTBUILD("Walnut","Pecan")
   SET y=$LISTBUILD("Apple","Pear",$LISTBUILD("Walnut","Pecan"))
   SET z=$LISTBUILD("Apple","Pear",,"Pecan")
   WRITE !,$LISTVALID(w_x) ; concatenated
   WRITE !,$LISTVALID(y)   ; nested
   WRITE !,$LISTVALID(z)   ; omitted element

The following examples all return 1. $LISTVALID considers all of the following “empty” lists as valid lists:

  WRITE $LISTVALID(""),!
  WRITE $LISTVALID($LB()),!
  WRITE $LISTVALID($LB(UndefinedVar)),!
  WRITE $LISTVALID($LB("")),!
  WRITE $LISTVALID($LB($CHAR(0))),!
  WRITE $LISTVALID($LB(,))

See Also

FeedbackOpens in a new tab