Lists
A little while ago you learned that all ObjectScript data are strings. A list is a special kind of string, made up of a list of items. There are several functions for working with lists, similar to string functions covered earlier.
-
$ListBuild returns a list built from items.
-
$List returns a specific item in the list.
-
$ListLength returns the number of items in the list.
-
$ListFind searches the list for an item, and returns its item number.
SAMPLES>set addr = "One Memorial Drive", city = "Cambridge"
SAMPLES>set st = "MA", zip = "02142"
SAMPLES>set mail = $listbuild(addr, city, st, zip)
SAMPLES>write $list(mail, 2)
Cambridge
SAMPLES>write $listlength(mail)
4
SAMPLES>write $listfind(mail, "MA")
3
SAMPLES>
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.