sysLib.size

The system function sysLib.size returns the number of rows in the specified data table or the number of elements in the specified array. The array may be a structure-item array, a static array of data items or records, or a dynamic array of data items or records.


sysLib.size syntax diagram

arrayName

Name of the array or data table.

Definition considerations

The item to which the value is returned must be of type INT or the following equivalent: type BIN with length 9 and no decimal places.

If the array name (arrayName) is in a substructured element of another array, the returned value is the number of occurrences for the structure item itself, not the total number of occurrences in the containing structure (see Examples section).

The array name may be qualified by a package name, a library name, or both

An error occurs if you reference an item or record that is not an array.

Examples

This example uses the value returned by sysLib.size to control a loop:

  // Calculate the sum of an array of numbers
  sum = 0;
  i = 1;
  myArraySize = sysLib.size(myArray);

  while (i <= myArraySize)
    sum = myArray[i] + sum;
    i = i + 1;
  end

Next, consider the following record part:

  Record myRecordPart
    10 siTop CHAR(40)[3];
      20 siNext CHAR(20)[2];
  end

Given that you create a record based on myRecordPart, you can use sysLib.size(siNext) to determine the occurs value for the subordinate array:

  // Sets count to 2
  count = sysLib.size(myRecord.siTop.siNext);

Related reference
Arrays
System words in alphabetical order