Pointing to Structure Variables

When having Structure type variables in the project it will be possible to go and point to each single member by appropriately addressing the variable member selection for the function or logic concerned. In this case you need to specify the name of the structure variable concerned followed by the name of the member variable 's name to be accessed in the syntax. The name of the structure and the name of the member must be separated by the ':' character.

 

Let's suppose for example that you want to access a Tank level value (tank number 10 of 20 tanks existing on the plant) to which corresponds to the structure variable Tank10 (in which the prototype has been set with the ' Level' variable word), you need to specify:

 

Tank10:Level

 

which should be:

 

<struct name>:<member name>

 

Accessing structure variable members can be done through out the project, by assigning this syntax whether to the graphic, Alarms, Data Loggers of logic functions.

 

If the structure variables are being used within Basic Scripts make sure the ':' is replaced with the '_'  or "." character when accessing variables directly, without using the Movicon functions (GetVariableValue(), SetVariableValue(), etc). In addition to this you can use the ":" character by enclosing the variable between square brackets. The syntaxes entered are:

 

Sub Main()

Dim nVar as Integer

 

nVar = Tank10_Level

nVar = Tank10.Level

nVar = [Tank10:Level]

nVar = GetVariableValue("Tank10:Level)

End Sub

 

Caution! the use of "structure var name.member name" syntax is only enabled if the "General - Advanced - Intellisense" option has been enabled in the structure variable's properties.

 

Structure variables can be copied directly in the Basic Script to avoid using syntax for example when using sytax:

  SetVariableValue("Tank10",GetVariableValue("Tank11"))

where "Tank10" and "Tank11" are structure variables defined with the same type (prototipo).

 

Warning! This instruction only copies the numeric member types and not string types: string type members must be copied individually, for example using this instruction:

[Tank10:Material] =  [Tank11:Material]

 

 

Movicon also accepts the <:><member name> syntax for the graphic functions of symbols. However, in this case, you have to specify which is the Default Structure Variable for the symbol as described in the 'Default Structures in symbols' document.

 

 

See Also