Basic Script Expressions in Object properties

The animation characteristic settings available in Movicon objects (Displays, Rectangles, etc.) allow you to establish the variable and the relevant thresholds for activating the graphical functions. Movicon allows you to exploit a particular characteristic for activating the graphic functionalities: the association of a Basic Script string expression for command execution.

By using this concept, instead of a variable you can associate a on whole VBA expression, complete with variables and logic conditions, to execute the function desired. By doing this the value returned from the expression will be used  instead of the variable value.

 

 

This illustration shows how you can insert a Basic Script expression instead of a  variable, The value returned from the expression will be interpreted instead of the variable's.

 

Caution! Movicon script functions such as GetVariableValue(), SetVariableValue, QualityOf(), etc., cannot be used in basic expressions.  The basic expressions only support WinWrap mathematical operators as listed below.

 

 

VBA Expression Editor

The basic script expressions can be inserted directly instead of the variable. An editor window has also been provided to help the programmer to do this and which can be opened with the "Expression..." button found in the "Tag Browser" window:

 

 

This editor window is very handy as it provides all the operations needed for inserting expressions allowing major control over any errors.

Once the window has been opened for inserting a variable double click on the variable name from the list to the right. To insert a mathematical function use the corresponding button. The available functions are:

 

Operator

Description

And

AND binary operator

Or

OR binary operator

Not

NOT logic operator (inverts the variable's boolean value or the expression which follows it)

=

equal to binary operator

<>

different than  binary operator

>=

more than or equal to binary operator

<=

less than or equal to binary operator

(

open brackets

)

close brackets

+

addition

-

subtraction

*

multiplication

/

division

Abs()

absolute value (module)

Sqr()

Square root

Exp()

base power is  (2,718)

Cos()

cosine (in radiants)

Sin()

sine (in radiants)

Tan()

tangents (in radiants)

Atn()

arctangent

CBool()

conversion to  boolean (boolean)

CInt()

conversion to integer (integer)

CLng()

conversion to long (long)

CDbl()

conversion to decimal number with double precision (double)

 

Long expressions can be inserted by going to the beginning with the Enter key. When the expression inserted is not valid, an error message will show when confirming with the OK key.

 

Expressions may not be valid if producing a division by zero. When validating expressions, the variables are considered with the "1" value. Therefore, the "VAR00001/(VAR00002-1)" expression will not be validated by the expression editor because it produces a division by zero.

 

Using the VBA expressions inside objects is quite fast even under Windows CE, and should be considered that it require less resources than writing code inside object events. In fact, just only one thread is related to manage all the VBA expressions for the objects loaded into the memory, and these expressions are evaluated only when on change (event) of the related variable. This can be faster also than the IL Logic, because the VBA expression are evaluated on event, instead the IL Logic is executed continuously in a cycle.

 

This functionality allows you to extend  the drawing's graphical potentialities further. The variable associated to each one of the symbol or drawing graphic properties can in fact be substituted with Basic expressions which can contain combinations of more variables or logic or mathematical expressions.

 

When a symbol  containing a VBA expression is added on screen, i.e. "VAR00001 + VAR00002", Movicon acknowledges the use of the two "VAR00001 and VAR00002" variables and inserts them both in the project.

 

Caution! This functionality passes the expression inserted directly in the Basic Script interface, therefore the use of variables that begin with numeric characters or particular characters that include an underscore ("_") will not be admitted.

 

Caution! Basic expressions do not support decimal formats (i.e.  "x.x") but only  "x".  Therefore you should used decimal order divisions directly in the expression (es: (VAR00001+VAR00002)/10).

 

Warning! Local Screen Variables are not supported within Basic Expressions.

 

Warning! the  <VariableName>.<BitNumber>syntax cannot be used in Basic Expressions and you must use a mask to extract the Bit value needed.

 

 

 

See Also