A list is a special kind of ObjectScript string, made up of a list of items. Although they are similar to delimited strings using $Piece, you work with lists using list-specific functions.
$ListBuild returns a list built from items. Concatenating lists creates a new list.
$List returns a specific item in the list. You can use an asterisk (*) to represent the last item, and *-n to count items backwards from the end.
$ListLength returns the number of items in the list.
$ListFind searches the list for an item, and returns its item number.
USER>set addr = "One Memorial Drive", city = "Cambridge" USER>set st = "MA", zip = "02142" USER>set mail = $listbuild(addr, city, st, zip) USER>write $list(mail, 2) Cambridge USER>write $list(mail, *-1) MA USER>write $listlength(mail) 4 USER>write $listfind(mail, "MA") 3 USER>set office = $listbuild("InterSystems", "USA") _ mail USER>write $listlength(office) 6 USER>write $listfind(office, "MA") 5 USER>
You can't use a list function on a non-list string, or you'll get a <LIST> error. Likewise, you usually will not use string functions on a list. Note that the abbreviations for list functions are two or three letters.