F_VN_GetNumberOfElements

F_VN_GetNumberOfElements 1:

Gets the number of elements in the container. (Alternatively use interface method .getElementNum.)

Syntax

Definition:

FUNCTION F_VN_GetNumberOfElements : HRESULT
VAR_INPUT
    ipContainer       : ITcVnContainer;
END_VAR
VAR_IN_OUT
    nNumberOfElements : ULINT;
END_VAR
VAR_INPUT
    hrPrev            : HRESULT;
END_VAR

F_VN_GetNumberOfElements 2: Inputs

Name

Type

Description

ipContainer

ITcVnContainer

Container

hrPrev

HRESULT

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

F_VN_GetNumberOfElements 3: In/Outputs

Name

Type

Description

nNumberOfElements

ULINT

Returns the number of elements in ipContainer

F_VN_GetNumberOfElements 4: Return value

HRESULT

Further information

This function should not be used to iterate over the elements of a container. Use iterators to access the elements instead. In particular, the following code construct is not recommended:

hr := F_VN_GetNumberOfElements(ipContainer, ipNumber, hr);
FOR i:=0 TO (ipNumber-1) DO
    // access container elements
END_FOR

Since ipNumber is a UDINT (natural integer), a return value of ipNumber = 0 would cause an underflow.

Required License

TC3 Vision Base

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision