DUEMMEGI
MCP 4 – User's manual
Contatto
3.2.2- VAR, GLOBAL VAR and EXTERN VAR
The scripts allow to use how many variables are required for the execution of the program. The variables
used in the scripts must be explicitly declared. Essentially, the variables can be grouped in two classes:
Local: these variables will not be shared among the several scripts, therefore two variables having the
same name, but declared in two different scripts, will be separately handled; a local variable is created at
the input of the script and destroyed at the output of the same script
Global: these variables are shared among the scripts, and therefore they can be used by all the scripts. A
global variable, once created, will be kept also at the exit of a script, therefore each script always will read
the last value that has been assigned to the variable itself
The VAR instruction in a script defines a local variable, and the GLOBAL VAR instruction defines a global
variable. Since all variables in a script must be declared, the instruction EXTERN VAR informs a script that
the variable has been declared in another script.
In the following example, the variable TEMP1 is declared as local, both for script 1 and for script 2, while the
variable is shared by both script.
script
1
trigger
= 2
var
TEMP1
global var
TEMP2
…………
endscript
script
2
trigger
= 2
var
TEMP1
extern var
TEMP2
…………
endscript
The local variables used by a subroutine must be declared inside the subroutine itself, not in the script
containing it; in other words, if a local variable has been declared in a script, the same variable cannot be
accessible by a subroutine contained in the same script.
3.2.3- Logic and Mathematical operations
The scripts allow to execute the main logic and mathematical operations. The allowed logic and mathematical
operators are:
&
AND
|
OR
^
EXOR
!
NOT
+
Sum
-
Subtract
*
Multiply
/
Divide
=
Equal
No parenthesis are allowed in logic and mathematical operations and no more than one operation for each
line is allowed. Keep in mind that the result of the logic and mathematical operations is always a 16-bit integer
number. If the result is a negative number, then it will be in the two’s complement format.
DUEMMEGI
s.r.l. - Via Longhena, 4 – 20139 MILANO
Tel. 02/57300377 - Fax 02/55213686 –
www.duemmegi.it
Rel.: 1.2 October 2018
Page 33 of 87