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_SECDetails regarding the syntax of definition types are described in the section Module Declaration.
The definition
Variableis 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
VarArraymust identify the variable array uniquely.Var_Countdefines the input instance path of an integerVariableof the module function block. To be available in the editor for configuration this variable must be defined as a parameter. Alternatively the variableVar_Countof Slot_Multi or InstRef_Multi can be used for defining this variable. Multiple VarArrays can use the sameVar_Countvariable. If the array size is 0, no array will be generated and the pointer of the array will be set to 0.Inst_Namedefines 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%.Pragmascontains a list of compiler pragmas, which will be inserted before the generated array variable.Var_Decl_Flagscan 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_SECAmong other declarations the declaration part of the function block must contain: uiArraySize: UINT := 7; psNameList: POINTER TO STRING;.