3 smc_varlist structure, Smc_varlist structure, L-force | plc designer - softmotion – Lenze PLC Designer PLC-Designer (R2-x) SoftMotion User Manual
Page 253

DMS 5.2 EN 03/2011 TD17
L
253
L-force | PLC Designer - SoftMotion
The SM_FileFBs.lib library
CNC function blocks
11.1.3
SMC_VARLIST structure
IEC 1131-3 does not make provision for acquiring the value of a variable from its symbolic
name, which is available, for example, as a string. This must be possible, however, if the
variable functionality available to the user with the "Create variable on compile"
compilation option is also to be used when reading in the CNC program from a file. The
SMC_VARLIST structure can be used to achieve this. The structure consists of the
wNumberVars variable, which contains the number of variables used, and a pointer,
psvVarList, which points to the first element of an array of SMC_SingleVar containing the
type and a pointer to the variable. An SMC_SingleVar object contains the character string
strVarName, which in turn contains the name of the variable as it appears in the CNC
program, in capital letters. Besides that it also provides a pointer to the variable and its
type.
Example: The CNC program that is read from a file using SMC_ReadNCFile contains two
variables, g_rTestX (REAL) and g_byCommand (BYTE):
Now define the following variables:
Prior to calling the SMC_ReadNCFile program organisation unit whose pvl input will then
be fed with ADR(vl), you must set the pointer to the variables:
You must also link SMC_VarList to AMC_SingleVar:
If a variable cannot be replaced, an error will be output and the program organisation unit
will abort.
N0 G$g_byCommand$ X$g_rTestX$
g_byCommand: BYTE;
g_rTest: REAL;
asv: ARRAY[0..1] OF SMC_SingleVar :=
(strVarName:='G_BYCOMMAND', eVarType:=SMC_TYPE_BYTE),
(strVarName:='G_rTESTX', eVarType:=SMC_TYPE_REAL);
vl: SMC_VarList:=(wNumberVars:=2);
asv[0].pAdr:=ADR(g_byCommand);
asv[1].pAdr:=ADR(g_rTest);
vl.psvVarList := ADR(asv[0]);