4D v16.3

Count list items

Home

 
4D v16.3
Count list items

Count list items 


 

Count list items ( {* ;} list {; *} ) -> Function result 
Parameter Type   Description
Operator in If specified, list is an object name (string) If omitted, list is a list reference number
list  ListRef, String in List reference number (if * omitted), or Name of list type object (if * passed)
Operator in If omitted (default): Return visible list items (expanded) If specified: Return all list items
Function result  Longint in Number of visible (expanded) list items (if 2nd * omitted) or Total number of list items (if 2nd * present)

The Count list items command returns either the number of items currently “visible” or the total number of items in the list whose reference number or object name you pass in list.

If you pass the first optional * parameter, you indicate that the list parameter is an object name (string) corresponding to a representation of the list in the form. If you do not pass this parameter, you indicate that the list parameter is a hierarchical list reference (ListRef). If you only use a single representation of the list or work with all the items (the second * is passed), you can use either syntax. Conversely, if you use several representations of the same list and work with the visible items (the second * is omitted), the syntax based on the object name is required since each representation can have its own expanded/collapsed configuration.

Note: If you use the @ character in the name of the list object and the form contains several lists that match with this name, the Count list items command will only apply to the first object whose name corresponds.

Use the second * parameter to determine which type of information will be returned. When this parameter is passed, the command returns the total number of items present in the list, regardless of whether it is expanded or collapsed.

When this parameter is omitted, the command returns the number of items that are visible, depending on the current expanded/collapsed state of the list and its sublists.

You apply this command to a list displayed in a form.

Here a list named hList shown in the Application environment:

 $vlNbItems:=Count list items(hList) ` at this point $vlNbItems gets 8
 $vlNbTItems:=Count list items(hList;*) `$vlNbTItems also gets 8

 $vlNbItems:=Count list items(hList) ` at this point $vlNbItems gets 2
 $vlNbTItems:=Count list items(hList;*) `$vlNbTItems still gets 8

 $vlNbItems:=Count list items(hList) ` at this point $vlNbItems gets 5
 $vlNbTItems:=Count list items(hList;*) `$vlNbTItems still gets 8



See also 

List item position
Selected list items

 
PROPERTIES 

Product: 4D
Theme: Hierarchical Lists
Number: 380

 
HISTORY 

Modified: 4D v11 SQL

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)