Contatto
MCP 4 – User's manual
DUEMMEGI
The syntax used to specify what method must be applied to each passed parameter is the following:
SUB NAMESUB( PAR1, PAR2, [PAR3], [PAR4])
Where:
PAR1
and
PAR2
are parameters passed as value
PAR3
and
PAR4
are parameters passed as reference, being surrounded by square brackets
To specify that a parameter must be interpreted as reference is thus necessary an enough to surround the
related parameter by square brackets in the line defining the subroutine (and only in that line).
Note: parameters of bit type (e.g. V1, O3.2, I4.3, etc.) cannot be passed as reference;
these parameters
can be passed as value only.
The following two examples show each one a calling to subroutine with parameters:
call
SETUP(
R0
,
AO1
, 128)
calling to subroutine to which 3 parameters are passed; there
.........
is not a value returned by the subroutine.
The parameter
AO1
will be passed as reference, therefore
the subroutine can change the value of the parameter itself.
sub
SETUP(REG, [OUT], K)
R0
, on the contrary, will be passed as value, therefore the
.........
subroutine cannot change the original value contained in the
endsub
parameter itself.
Last parameter is a numerical constant value.
R100
= CALCULATE(
R10
,
R11
)
function to which 2 parameters are passed and which will
.........
return a value copied in
R100
.
The parameter
R11
will be passed as reference, therefore
the function can change the value of the parameter itself.
sub
CALCULATE(REG1, [REG2])
R10
, on the contrary, will be passed as value, therefore the
.........
function cannot change the original value contained in the
endsub
parameter itself.
Notes:
a Subroutine or a Function, when called by a script other than the script where the function was included,
must be placed before the calling itself.
if a subroutine uses local variables, these ones must be declared inside the subroutine itself.
a Subroutine can call another Subroutine for a max total of 16 nested calls.
For the subroutines and the functions without parameters, the following points must be taken in
account:
1. if a subroutine or a function does not require input parameters, it
must be however
declared
using the parenthesis "()" without the parameters list; for instance:
sub
TEMPERATURE()
2. the calls to subroutines or functions without parameters can be written with or without
parenthesis; for instance, the following calls are exactly equivalent:
R0
= TEMPERATURE()
R0
= TEMPERATURE
call
TEMPERATURE()
call
TEMPERATURE
Page 38 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