CltsEveryBool

This function checks whether all elements of a boolean array have the same value as the bTest function input parameter.

Namespace: Tc3_Collections
Library: Tc3_Collections (Tc3_Collections.compiled-library)

Syntax

FUNCTION CltsEveryBool : BOOL
VAR_INPUT
    bTest: BOOL;
END_VAR
VAR_IN_OUT
    in: ARRAY[*] OF BOOL;
END_VAR
VAR_OUTPUT
    index: DINT;
END_VAR

CltsEveryBool 1: Inputs

Name

Type

Description

bTest

BOOL

Test value that is compared with all array elements.

CltsEveryBool 2: Inputs/outputs

Name

Type

Description

in

ARRAY[*] OF BOOL

The boolean array variable to check.

CltsEveryBool 3: Outputs

Name

Type

Description

index

DINT

Index number of the first array element whose value is not equal to the bTest input parameter. This value is 0 if the function return parameter is "TRUE".

CltsEveryBool 4: Return value

Name

Type

Description

CltsEveryBool

BOOL

"TRUE" if all array elements have the same value as the bTest function input parameter. "FALSE" if at least one array element has an unequal value like the bTest function input parameter.

Sample

PROGRAM MAIN
VAR
    a: ARRAY[1..5] OF BOOL;
    index: DINT;
    bResult: BOOL;
END_VAR
a[1]:=FALSE;
a[2]:=FALSE;
a[3]:=TRUE;
a[4]:=FALSE;
a[5]:=TRUE;
bResult:=CltsEveryBool(bTest:=TRUE, in:=a, index=>index);(* return value is FALSE, index = 1 *)
bResult:=CltsEveryBool(bTest:=FALSE, in:=a, index=>index);(* return value is FALSE, index = 3 *)
a[1]:=TRUE;
a[2]:=TRUE;
a[4]:=TRUE;
bResult:=CltsEveryBool(bTest:=TRUE, in:=a, index=>index);(* return value is TRUE, index = 0 *)