Contatto
MCP 4 – User's manual
DUEMMEGI
The following script shows some examples about Logic and mathematical operations.
script
1
trigger
= 1
R0
=
R1
+
R2
R0
=
R0
+ 10
AO1
=
R100
/ 2
R50
=
R51
&
0b1111111100000000
endscript
An operation of the type VAR = VAR [op] K, where VAR is a variable, K is a constant number and [op] is one
of the described logic/mathematical operators (= excluded), the optional notation VAR += 10 can be used.
For instance
R0
=
R0
+ 10 and
R0
+= 10
are absolutely equivalent notations.
3.2.4- IF…THEN…ELSE…ENDIF
The IF…THEN…ENDIF block allows to execute, if the specified condition is true, the instructions included
between THEN and ENDIF. If the condition is not true, then the execution will jump to ENDIF or to ELSE if
this has been specified (ELSE is an optional keyword). If ELSE has been specified, then the instruction
included between ELSE and ENDIF will be executed.
Each IF block must be always closed by an ENDIF which is mandatory (on the contrary to ELSE which is
optional).
The condition of the block IF…THEN…ENDIF must be specified using the following comparison operators:
>
Greater than
>=
Greater than or equal to
= =
Equal to
<
Less than
<=
Less than or equal to
!=
Not equal to
The following script includes two IF…THEN…ENDIF blocks; note that the first block is written on the same
line, therefore the “;” symbol must be used to split the several instructions. The second IF…THEN…ENDIF
block, on the contrary, is written on more lines, therefore the “;” symbol is not required.
SCRIPT
1
TRIGGER
= 1
IF
R0
>25
THEN
;
R0
=1;
ENDIF
IF
R0
==0
THEN
R1
=140
R2
=50
V1
=1
ENDIF
ENDSCRIPT
The following script includes an IF block with ELSE.
SCRIPT
1
TRIGGER
= 1
IF
I4.7
= 1
THEN
O1.1
=
I1.1
ELSE
O1.1
= 0
ENDIF
ENDSCRIPT
Page 34 of 87
Rel.: 1.2 October 2018
DUEMMEGI
s.r.l. - Via Longhena, 4 – 20139 MILANO
Tel. 02/57300377 - Fax 02/55213686 –
www.duemmegi.it