F_CheckMemoryArea

F_CheckMemoryArea 1:

The function returns information about the memory area in which the requested variable with the specified size is located. A return value of type E_TcMemoryArea is used for this purpose.

FUNCTION F_CheckMemoryArea: E_TcMemoryArea

F_CheckMemoryArea 2: Inputs

VAR_INPUT
    pData : PVOID;
    nSize : UDINT;
END_VAR

Name

Type

Description

pData

PVOID

Memory address of the variable

nSize

UDINT

Size of the variable in bytes

Example

PROGRAM MAIN
VAR
    nCounter : USINT;
    eMemAreaStatic : E_TcMemoryArea;
    pDynamicVariable : POINTER TO LREAL;
    eMemAreaDynamic : E_TcMemoryArea;
    pNull : PVOID := 0;
    eMemAreaUnknown : E_TcMemoryArea;
END_VAR
-------------------------------------------------------------------

nCounter := nCounter + 1;
eMemAreaStatic := F_CheckMemoryArea( pData:=ADR(nCounter), nSize:=SIZEOF(nCounter) );

IF nCounter = 100 THEN
    pDynamicVariable := __NEW(LREAL);
    IF pDynamicVariable <> 0 THEN
        pDynamicVariable^ := 7 * 4.5; 
        eMemAreaDynamic := F_CheckMemoryArea( pData:=pDynamicVariable, nSize:=SIZEOF(LREAL) );
        __DELETE(pDynamicVariable);
    END_IF
END_IF

eMemAreaUnknown := F_CheckMemoryArea( pData:=pNull, nSize:=1 );

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.4022

PC or CX (x86, x64, ARM)

Tc2_System (system)