Section: VarArrays
The parameter VarArrays
allows to create arrays with configurable size.
SEC VarArrays //optional: yes, modifier: [UPDATE]] SEC VarArray : <slot identifier> //optional: yes, modifier [] Variable := <variable name>; //optional: no, type: InstancePath Var_Count := <variable count>; //optional: no, type: InstancePath Inst_Name := <instance name>; //optional: yes, type: StringLiteral Pragmas := [<pragma1>, <pragma2>,...]; //optional: yes, type: Pragmalist Var_Decl_Flags := <Flag1> | <Flag2> | ... ; //optional: yes, type: Flags END_SEC END_SEC
Details regarding the syntax of definition types are described in the section Module Declaration.
The definition
Variable
is an input instance path relative to the module function block. The data type isPOINTER TO <ELEMTYPE>
.<ELEMTYPE>
can be any data type.The target of a section
VarArray
must identify the variable array uniquely.Var_Count
defines the input instance path of an integerVariable
of the module function block. To be available in the editor for configuration this variable must be defined as a parameter. Alternatively the variableVar_Count
of Slot_Multi or InstRef_Multi can be used for defining this variable. Multiple VarArrays can use the sameVar_Count
variable. If the array size is 0, no array will be generated and the pointer of the array will be set to 0.Inst_Name
defines the name of the created array variable. The placeholder%Instancename%
and%VariablePath%
(upper or lower case spelling is not relevant) will be replaced by the instance name of the module instance resp. the instance path of the pointer variable. Points will be replaced by underlines. If the definition is omitted the default valueAC_ARRAY_%VariablePath%
. is used.An error will be created if two different VarArrays of a module have the same
Inst_Name
, which does not include the placeholder%VariablePath%
.Pragmas
contains a list of compiler pragmas, which will be inserted before the generated array variable.Var_Decl_Flags
can be used to specify the variable type of the created array. Possible flags areNONE
,RETAIN
, andPERSISTENT
. These flags are added to the variable sectionVAR_INPUT
, in which the array is created. (example: for the flagRETAIN
,VAR_INPUT RETAIN
).
SEC VAR_ARRAYS SEC VAR_ARRAY : NameList Variable := psNameList; Var_Count := uiArraySize; END_SEC ... SEC PARAM : ArraySize Variable := uiArraySize; Name := TL.ArraySize_Name; Desc := TL.ArraySize_Desc; END_SEC END_SEC
Among other declarations the declaration part of the function block must contain: uiArraySize: UINT := 7; psNameList: POINTER TO STRING;
.