More List Functions
Additional functions for working with lists:
-
$ListValid determines whether a string is a list.
-
$ListFromString returns a list built from a delimited string.
-
$ListToString returns a delimited string built from a list.
-
$ListSame compares 2 lists item by item, and returns 1 if they are identical, 0 otherwise.
-
$ListNext advances sequentially from one list item to the next.
-
Set $ListBuild sets a list of variables to a list of values, one by one.
The $ListNext function changes the value of its second and third arguments.
SAMPLES>set addr = "One Memorial Drive", city = "Cambridge"
SAMPLES>set st = "MA", zip = "02142"
SAMPLES>set Pmail = addr _ "^" _ city _ "^" _ st _ "^" _ zip
SAMPLES>set Lmail = $listfromstring(Pmail, "^")
SAMPLES>write $listvalid(Lmail)
1
SAMPLES>write $listvalid(Pmail)
0
SAMPLES>write $list(Lmail, 2)
Cambridge
SAMPLES>write $listlength(Lmail)
4
SAMPLES>write $listfind(Lmail, "MA")
3
SAMPLES>set Pmail = $listtostring(Lmail,"*")
SAMPLES>write Pmail
One Memorial Drive*Cambridge*MA*02142
SAMPLES>set Lmail2 = $listbuild("One Memorial Drive","Cambridge","MA","02141")
SAMPLES>write $listsame(Lmail, Lmail2) // not the same because of different zip
0
SAMPLES>set p = 0 while $listnext(Lmail, p, value) { write !, value }
One Memorial Drive
Cambridge
MA
02142
SAMPLES>set $listbuild(addr2, city2, st2, zip2) = Lmail2
SAMPLES>write addr2, !, city2, !, st2, !, zip2
One Memorial Drive
Cambridge
MA
02141
SAMPLES>