assistance-engine/docs/developer.avapframework.com/appendices_10.md

1.2 KiB

getListLen()

The getListLen() command calculates the length of a list and stores the result in a target variable. This command is useful for determining the number of elements in a list.

Parameters

  • SourceVariable Type: var Description: The variable containing the list whose length you want to calculate. It can be a variable that stores the list or a direct value representing the list.
  • TargetVariable Type: var Description: The variable where the result of the list length will be stored. This should be a variable that will receive the integer value representing the number of elements in the list.

Command Flow

Usage Example

Suppose the list in myList is ['apple', 'banana', 'cherry'] .

// Variable definitions
myList = ['apple', 'banana', 'cherry']
listLength = 0

// Call the command to calculate the length of the list
getListLen(myList, listLength)

// Return the list length through addResult
addResult(listLength)

Since the list myList has 3 elements, the getListLen() command will calculate that the length is 3. This value will be stored in the listLength variable and returned through addResult(listLength) , resulting in the following output:

3