F_BA_Cmp

F_BA_Cmp 1:

The function F_BA_Cmp of return type DINT compares two memory areas of the same size. Here pValue defines the beginning of the observation area and pCompare the beginning of the area to be compared. It is compared byte by byte. As soon as a byte is found in the observation area which is smaller than the one of the area to be compared, the function aborts the comparison and takes the return value "-1". If a byte is found in the observation area that is larger than that of the area to be compared, the function also aborts and takes the return value "1". If, on the other hand, no difference is found, i.e. all bytes of the observation area are identical to those of the area to be compared, the function assumes the value "0" at the end of the comparison.

The output nEqualBytes shows how many bytes were equal before the comparison operation was completed or aborted.

The input variable nSize defines the size of the two memory areas.

In case of an incorrect input, i.e. pValue = 0 or nSize = 0, the function is also aborted immediately and takes "-1" as return value.

Syntax

FUNCTION F_BA_Cmp : DINT
VAR_INPUT
  pValue         : PVOID;
  pCompare       : PVOID;
  nSize          : UXINT;
END_VAR
VAR_OUTPUT
  nEqualBytes    : UINT;
END_VAR

F_BA_Cmp 2: Inputs

Name

Type

Description

pValue

PVOID

Pointer to the beginning of the memory area to be examined.

pCompare

PVOID

Pointer to the beginning of the memory area to be compared.

nSize

UXINT

Length of the memory area.

F_BA_Cmp 3: Outputs

Name

Type

Description

nEqualBytes

UINT

Display how many bytes were equal before the comparison operation was completed or aborted.

Requirements

Development environment

Required PLC library

TwinCAT 3.1 4024.35

Tc3_BA2_Common from V2.1.20.0