CountOf

PLCopen motion icon

 FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. - Returns the number of items in an array.

Inputs

Input

Data Type

Range

Unit

Default

Description

ARR

Any

 

 

 

Declared array.

Outputs

Output

Data Type

Range

Unit

Description

Q

DINT

 

 

Total number of items in the array.

Remarks

Example

   FOR i := 1 TO CountOf (MyArray) DO
      MyArray[i-1] := 0;
   END_FOR;

Examples

Array

Return

Arr1 [ 0..9 ]

10

Arr2 [ 0..4 , 0..9 ]

50

FBD Language Example

FFLD Language Example

  • In the FFLD Language, the operation is executed only if the input rung (EN) is TRUE.
    • The output rung (ENO) keeps the same value as the input rung.
    • The function is executed only if EN is TRUE.

IL Language Example

Not available.

ST Language Example

Q := CountOf (ARR);