その他のリスト関数
リストの操作に使用できるその他の関数:
-
$ListValid は、文字列がリストかどうかを判断します。
-
$ListFromString は、区切り文字列から生成されたリストを返します。
-
$ListToString は、リストから生成された区切り文字列を返します。
-
$ListSame は、2 つのリストの各項目を比較し、同一の場合は 1 を、それ以外の場合は 0 を返します。
-
$ListNext は、1 つのリスト項目を順次進め、次に進んだ場合は 1 を返し、最後に到達した場合は 0 を返します。また、2 番目と 3 番目の引数の値をそれぞれ、リスト位置と、その位置にある項目の値に変更します。
-
Set $ListBuild は、変数のリストをリストの項目に設定します。これは、"リストの解体" と考えることができます。
ターミナル
USER>set addr = "One Memorial Drive", city = "Cambridge"
USER>set st = "MA", zip = "02142"
USER>set Pmail = addr _ "^" _ city _ "^" _ st _ "^" _ zip
USER>set Lmail = $listfromstring(Pmail, "^")
USER>write $listvalid(Lmail)
1
USER>write $listvalid(Pmail)
0
USER>write $list(Lmail, 2)
Cambridge
USER>write $listlength(Lmail)
4
USER>write $listfind(Lmail, "MA")
3
USER>set Pmail = $listtostring(Lmail, "*")
USER>write Pmail
One Memorial Drive*Cambridge*MA*02142
USER>set Lmail2 = $listbuild("One Memorial Drive", "Cambridge", "MA", "02141")
USER>write $listsame(Lmail, Lmail2) // not the same because of different zip
0
USER>set p = 0 while $listnext(Lmail, p, value) {write !, value}
One Memorial Drive
Cambridge
MA
02142
USER>set $listbuild(addr2, city2, st2, zip2) = Lmail2
USER>write addr2, !, city2, !, st2, !, zip2
One Memorial Drive
Cambridge
MA
02141
USER>