beautypg.com

L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 592

background image

L-force | PLC Designer

General Editors

590

DMS 4.1 EN 03/2011 TD29

Example
A CFC program cfc_prog handles an instance of function
block fubblo1, which has an input variable struvar of type
of a structure. By using the composer element the
structure components can be accessed:
Structure stru1 definition:
TYPE stru1 :
STRUCT
ivar:INT;
strvar:STRING:='hallo';
END_STRUCT
END_TYPE

Function block fublo1, declaration and implementation:
FUNCTION_BLOCK fublo1
VAR_INPUT
struvar:STRU1;
END_VAR
VAR_OUTPUT
fbout_i:INT;
fbout_str:STRING;
END_VAR
VAR
fbvar:STRING:='world';
END_VAR

fbout_i:=struvar.ivar+2;
fbout_str:=CONCAT (struvar.strvar,fbvar);

Program cfc_prog, declaration and implementation:
PROGRAM cfc_prog
VAR
intvar: INT;
stringvar: STRING;
fbinst: fublo1;
erg1: INT;
erg2: STRING;
END_VAR