Builds a list of elements from the specified expressions.
||Element values to include in a Caché list. An expression that resolves to a number or string. Commonly, multiple element values are specified, separated by commas. To include a comma within an element, make the element a quoted string.
takes one or more element
values and returns a Caché list structure containing a corresponding list of elements.
The following functions can be used to create a list:
, which creates a list from multiple strings, one string per element.
, which creates a list from a single string containing multiple delimited elements.
, which extracts a sublist from an existing list.
and the other $LIST functions use an optimized binary representation to store data elements. For this reason, equivalency tests may not work as expected with some $LIST data. Data that might, in other contexts, be considered equivalent, may have a different internal representation. For example, $LISTBUILD(1)
is not equal to $LISTBUILD(1)
For the same reason, a list string value returned by $LISTBUILD
should not be used in character search and parse functions that use a delimiter character, such as $PIECE
and the two-argument form of $LENGTH
. Elements in a list created by $LISTBUILD
are not marked by a character delimiter, and thus can contain any character.
The following example produces the three-element list "Red,Blue,Green":
Omitting an element expression yields an element whose value is undefined. For example, the following $LISTBUILD
statement produces a three-element list whose second element has an undefined value; referencing the second element with the $LIST
function will produce a <NULL VALUE> error.
However, the following produces a three-element list whose second element is a null string. No error condition exists.
Additionally, if a $LISTBUILD
expression is undefined, the corresponding list element has an undefined value. The following two expressions both produce the same two-element list whose first element is "Red" and whose second element has an undefined value:
Providing No Parameters
Invoking the $LISTBUILD
function with no parameters returns a list with one element whose data value is undefined. This is not the same as a null string:
An element of a list may itself be a list. For example, the following statement produces a three-element list whose third element is the two-element list, "Walnut,Pecan":
The result of concatenating two lists with the Concatenation Operator (:) is another list. For example, the following two WRITE
statements produce the same list, "A,B,C":
A null string ("") is an empty list. For example, the following two expressions each produce the same two-element list:
However, the following two expressions each produce a three-element list:
If one or more characters in a list element is a wide (Unicode) character, all characters in that element are represented as wide characters. To ensure compatibility across systems, $LISTBUILD
always stores these bytes in the same order, regardless of the hardware platform. Wide characters are represented as byte strings. Therefore, the length reflects the number of bytes, not the number of Unicode characters.
In the following example, the first element has a length of ten: four characters, each two bytes long, plus the length and data type bytes. The data type byte is 02 (Unicode string). Each character is represented by two bytes in little-endian order. The second element has a length of five: three characters, plus the length and data type bytes. The data type byte is 01 (Binary string).
© 1997-2019 InterSystems Corporation, Cambridge, MA