Plc programming – Lenze ETC Motion Control User Manual
Page 385

PLC programming
Library
FILE IO functions
8.8
8.8.3
l
385
EDSTCXN EN 2.0
8.8.3.5
SYSCLOSEFILE
FUNCTION SYSCLOSEFILE: DINT
VAR_INPUT
handle_di
: DINT;
END_VAR
The function is used to close a file previously opened with SysOpenFile(). The
content of the FLASHPROMs is only updated in the FLASHPROM after the last
file opened for write−access has been closed. The return value of the function
is less than 0 for an error (all error codes are defined in the global constants
of the library).
handle_di
File handle (returned by SysOpenFile())
8.8.3.6
SYSREADFILE
FUNCTION SYSREADFILE: DINT
VAR_INPUT
handle_di
: DINT;
(* File handle returned by SysOpenFile *)
buffer_p
: DINT;
(* Address of a buffer where the data are stored *)
maxlen_di
: DINT;
(* Buffer length in byte *)
END_VAR
The function is used for reading blocks (in sequence) from a file previously
opened with SysOpenFile(). A maximum of maxlen_di characters are read
from the file into the buffer defined with buffer_p. Less than maxlen_di
characters will only be read if the file end is reached before or a read error
occurs.
Return value: Actual number of read characters; 0 for file end or less than 0
for error (
¶ 391).
handle_di
: DINT;
num_di
: DINT;
ret_di
: DINT;
buffer_from
: ARRAY[0..100] OF BYTE;
handle_di
:= SYSOPENFILE(’test.dat’, O_RDONLY);
num_di
:= SYSREADFILE(handle_di, ADR(buffer_from), 20);
ret_di
:= SYSCLOSEFILE(handle_di);
Declaration
Description
Parameters
Declaration
Description
Example