Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

リスト

区切り文字のことを考えたくない場合に、リストは便利です。区切り文字を使用すると、常に部分文字列のいずれかに区切り文字が含まれ、文字列の各構成部の位置を混乱させる可能性が生じます。リストはこれを防ぎます。

Piece() と同様に、List() は他にも特徴があります。単一の項目ではなく、項目リストを返します。空の部分文字列が存在する場合、List() は <NULL VALUE> エラーを生成し、ListGet() は空文字列を返します。

addr = "One Memorial Drive" : city = "Cambridge" : st = "MA" : zip = "02142"
mail = listbuild(addr, city, st, zip)
println "city = ", list(mail, 2)
println "5th (empty) item = ", listget(mail, 5)
cityst = list(mail, 2, 3)
println "state = ", list(cityst, 2)
println "count of items = ", listlength(mail)
println "MA is item #", listfind(mail, "MA")

通常の文字列では、List 関数は <LIST> エラーが検出されるため、使用できません。同様に、リストでは文字列関数を使用しません。$ListBuild で構築される文字列は Println コマンドで表示できますが、制御文字を含むため、お勧めできません。したがって、専用の List 関数を使用してリストにアクセスするようにします。

FeedbackOpens in a new tab