L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 525

Advertising
background image

L-force | PLC Designer

Data types in PLC Designer



DMS 3.2 EN 02/2011 TD29

523

Example:

pt:POINTER TO INT;

var_int1:INT := 5;

var_int2:INT;

pt := ADR(var_int1);

var_int2:= pt^; (* var_int2 is now 5 *)

Checking pointer accesses at runtime

For checking pointer accesses during runtime you can create check functions, which
will be called automatically before each access on the address of a pointer. For this
purpose the respective function must be available in the project, directly or via a
library. The following functions are supported:

• Function CheckPointer: checks whether the address currently stored at the pointer

is within the valid memory range,

• Function CheckPointerAligned: implicates the functionality of CheckPointer and

additionally checks the memory alignment.

The functions must exactly have the mentioned names. They return the address

which is used for dereferencing the pointer, thus at best that which has been passed
on as the first input parameter (dwAddress in the example shown below).

See in the following example of a CheckPointerAligned function, which input
parameters are processed. The parameter names are examples too. A CheckPointer
function must look the same, except that there may be no parameter for the
granularity of the pointer access:

FUNCTION CheckPointerAligned
: DWORD

(* The data type of the
function (return value) must
be the same as used for
pointers in the currently set
target system; i.e. DWORD for
systems using 32-bit
pointers, WORD for systems
using 16-bit pointers *)

VAR_INPUT

dwAddress : DWORD;

(* Target address of the
pointer; the data type must
be the same as used for
pointers in the currently set
target system, see above:
return value *)

Advertising