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?

ListLength

リストにある要素の数を返します。

Synopsis

ListLength(list)

引数

list 有効なリストとして評価される式。Caché list は、ListBuild、または ListFromString を使用して作成するか、List を使用して別のリストから抽出する必要があります。NULL 文字列 ("") も、有効なリストと見なされます。

概要

ListLength は、list にある要素の数を返します。要素にデータ値があるかどうかに関係なく、リスト内のすべての要素をカウントします。

以下の例は ListLength 関数の使用法を示しています。

myList = ListBuild("Red","Blue","Green","Yellow")
Println ListLength(myList) 'prints 4

以下の例は、ListLength によってすべてのリスト要素をカウントする方法を示しています。

GapList = ListBuild("Red",, "Green", "Yellow")
UndefVarList = ListBuild("Red",x, "Green", "Yellow")
NullStrList = ListBuild("Red","", "Green", "Yellow")
Println ListLength(GapList)        ' prints 4
Println ListLength(UndefVarList)   ' prints 4
Println ListLength(NullStrList)    ' prints 4

以下の例は、ListLength による NULL 文字列、および NULL 文字列要素のみが含まれるリストの処理方法を示しています。

Println ListLength("")       '  prints 0
NullList = ListBuild("")
Println ListLength(NullList) '  prints 1

関連項目

FeedbackOpens in a new tab