Movicon Help on Line - Rel. 11.7.1301
The Alias management objects consists in the possibility to insert an Alias in object variable or text fields instead of the variable or text names (static or string ID). After which a table can be edited with the Alias names corresponding to with the variables, constants or texts to be used in the object in runtime mode afterwards. Movicon will replace the Alias identifications with the corresponding elements in the table when loading symbols in runtime. In this way all the objects will be the equal, with the same Aliases defined in the properties and with the Table's different correspondences.
This type of Alias mechanism may result particularly useful when using "Public Symbols". In this case the "Preserve Variables" property is also fundamental through which variables from the reference symbol can be inherited, in this case being the Aliases.
The Alias can only be managed in object properties and are not supported in the object's IL logic or Basic Script code. Nevertheless, an Alias can also be used in the object's basic script expression. |
Alias syntax
In order to understand whether an Alias has been inserted in a field it is necessary that this Alias respects a certain syntax. This Alias identifier syntax must be written within double angled brackets: <<AliasName>>.
The Alias, as mentioned before, can be replaced with the name of a variable, a constant or a text. The possible combinations in which an Alias can be used are as follows:
Inserting Aliases in Variable fields
Aliases can be inserted in variable fields belonging to objects and in the objects' command lists' variable fields. Aliases can be inserted in variable fields in the following possible ways:
Variable name : <<AliasVariable>>
Pointing to variable bits: <<AliasVariable>>.0, VAR00001.<<AliasBit>>, <<AliasVariable>>.<<AliasBit>>
Struture Variable: <<AliasStruct>>:VAR00001, StructVar:<<AliasMember>>, <<AliasStruct>>:<<AliasMember>>, <<AliasStruct>>:<<AliasMember>>.<<AliasBit>>
Array Variable: <<AliasArray>>.e0, <<AliasArray>>[0], ArrayVariable.e<<AliasElement1>>, ArrayVariable<<AliasElement2>>, <<AliasArray>>.e<<AliasElement1>>, <<AliasArray>><<AliasElement2>>
Basic Expressions : <<AliasVariable>> + <<AliasConstant>>, <<AliasVariable>> + VAR00001, VAR00001 + <<AliasVariable>> + <<AliasConstant>>, [<<AliasStruct>>:<<AliasMember>>] + <<AliasVariable>>, (VAR00001 + <<AliasVariable>>) / 10, etc.
Using in Basic Script code: GetVariableValue(GetAlias("AliasVariable")), SetVariableValue(GetAlias("AliasVariable"), 10), etc.
The corresponding Alias table would result as:
ALIAS |
VALUE |
AliasVariable |
VAR00001 |
AliasBit |
0 |
AliasStruct |
StructVar |
AliasMember |
VAR00001 |
AliasArray |
ArrayVariable |
AliasElement1 |
1 |
AliasElement2 |
[0] |
AliasConstant |
10 |
Where VAR00001, StructVar and ArrayVariable are RealTimeDB variables and the others are only values.
Inserting Aliases in Text fields
Aliases can be also inserted in text field belonging to objects and in their Command List text fields. Some examples would be:
Object Name: <<AliasObjectName>>
Object Title: <<AliasObjecTitle>>
Static Image: <<AliasStaticImage>>
The corresponding Alias table would result as:
ALIAS |
VALUE |
AliasObjectName |
ObjMotor01 |
AliasObjecTitle |
Motor 1 |
AliasStaticImage |
Motor01.jpg |
Caution! Aliases uses in text fields are replaced only when loading the object. This means that Alias must be valued in the object's table of its style source container. In this case the screen's Alias Table will be ignored making it impossible to use it for changing the text field alias values. |
If the value associated to a text field alias is as a String ID from the project's String Table, the string ID text will be displayed in both development and runtime mode, in relation to the selected language. |
Alias Table
The Alias definitions, being value associations to Aliases, whether a variable, a simple numeric value or string, are done on the "Alias Table". Aliases can be defined both at simple object level, composed symbol level and also at screen level. The Alias table is saved in the xml code of the object or in the screen within which it was edited. If a composed symbol has been created, an Alias Table can be defined for each of the symbol's components and one can be defined for the style container source.
The Alias's resolution is done starting from the highest level to the lowest level. For example if an Alias has been inserted in a component its value will first be searched for in the component's table and if not found, it will then be searched for in the table of the parent/reference symbol containing it.
This will continue until the last symbol has been search for those symbols composed of diverse number of embedded sub-symbols. If by the end the search the Alias's value has still not been found, another search will take place in the Table defined in the Screen.
When the Alias Table is opened in an object, Movicon will carry out a control to check whether Aliases have been inserted in the object's properties and report the list of Aliases to the table. From this point on you can edit the Alias Table to associate values to the Aliases, insert new Aliases, delete or modify existing ones.
The Alias Table can be opened using the following commands:
An object/symbol's "General - Object alias editor" property
After having selected an object/symbol use Symbol Menu > "Edit Aliases..." command
the "Edit Aliases..." comand from menu which appears right doublie clicking on object/symbol
A screen's "General - Object alias editor" property for editing the screen's Alias Table
The Alias Table will open displayed as follows:
The table is composed of two columns, the first one shows the Alias name without the double angled brackets, the second shows the Alias to be replaced by the value , which may be a variable or a simple numeric or string value.
Alias values can also be set with an explicit Null value. In order to do this you will need to use the "(null)" keyword. Setting an alias with the null value, for instance in a display object, is the same as not associating this object with a variable. |
Using Aliases that contain expressions/calculations might cause the screen to take time opening due to the fact that this operation also involves the use of the script engine. The slow opening of the screen page largely depends of the characteristics of the device where Movicon is running and it usually more evident in Windows CE. |
Editing/Inserting Aliases
When the Alias Table is opened at object or symbol level, Movicon searches for the Aliases inserted in the symbol and then displays them. Values can be associated to Aliases when entering into edit mode from the field with a double click or using the F2 key followed by the TAB key to move from one to the next. On the other hand, if you right mouse click, a popup menu will appear through which you can perform the following operations:
New Alias: adds a new Alias to the Table list
Browse Variable (Tag): opens the Tag Browser window for selecting variables from the RealTimeDB to insert in the "Variable" (Tag)" column
Cut: eliminates the selected Alias
Copy: copies the selected Alias to the windows clipboard
Paste: pastes the Alias previously copied with an increasing index in the name
To delete an Alias just select the roe and use the "CANC" key.
Aliases inserted on object/symbol Alias Tables are saved in the object's code only if they have been associated with a value. This means that if a new Alias is added to the table and is not used in object's properties and doesn't get assigned with a value, it will not show next time the Alias Table is opened. However this behaviour does not happen with screen Alias Tables, where the inserted Aliases still get saved in the screen's xml code even though not valued.
Replacing Aliases in Runtime
Upon loading an object/symbol during runtime mode, any existing Aliases will get replaced statically with the value defined in the object's table or that of the symbol containing it. In this case, however, even though the Alias's value gets modified through the script functions (re. paragraph on "Handlig Aliases In Script Code"), the object is not influenced in any way and will continue to display the replaced value when loaded.
In cases where Aliases have not been valued in the object or style source symbol container's table, they will not get replaced with any values when the object is loaded, but will be resolved only after the object has been loaded in dynamic mode. In this case if the screen's Alias gets modified using the script functions (re. paragraph on "Handlig Aliases In Script Code"), the object will be re-initialized and displayed showing the new value associated to the Alias.
Caution! when associating the Configuration Files to an object that uses Aliases, when modifying the value of an Alias using the script functions, the configuration/settings file is reloaded and in this case the Alias will be reinitialized with the new value. If, however, the configuration/settings file is also saved the Alias management will go amiss because the file is saved inserting the value in the object's property which was replaced statically when the object was loaded and not the Alias. This, of course, is only if the object's Aliases have been defined in the object's table or that of the symbol container source. |
Aliases in the Dynamic Property Inspector Window
Aliases or objects and symbols are also displayed in the "Dynamic Property Inspector" window through which they can also be modified.
"Set Screen Alias"
You can select the "Set Screen Alias" from the "Variable" group from the Command List, through which you can modify/add Screen Aliases in runtime.
Handling Aliases in Script code
The Alias Table of an object or a screen can be also accessed in runtime using the purpose Basic Script functions. These functions can be used for retrieving Alias lists, values and perform modifications. The available set of functions predisposed for these purposes are listed below. For further information about these functions please refer to the relating paragraphs written in the VBA Language section.
The functions used for accessing Object Alias Tables can be found in the "DrawCmdTarget" interface and are:
GetAlias(_lpszAlias, _bRecursive)
SetAlias(_lpszAlias, _lpszValue)
The functions used for accessing Screen Alias Tables can be found in the "SynopticCmdTarget" interface and are:
SetAlias(_lpszAlias, _lpszValue)
Handling Aliases in Dropping Code
The above listed Basic Script functions can also be used in Dropping Template Code. In this way you can customize symbols while inserting them on screen from the Symbol Library.