ElmoMC Multi-Axis Motion Controller-Maestro User Manual
Page 94

Examples:
function int max_value = MAX_INT(int a, int b, int c)
int
max_a_b
if(a>b)
max_a_b = a
else
max_a_b = b
end
if
if(max_a_b
>
c)
max_value
=
max_a_b
else
max_value
=
c
end
if
end function
This function, named MAX_INT, has three integer input arguments (a, b, c) and one
integer return argument (max_value). The function body includes one declaration-
statement (local integer variable max_a_b) and two if-else statements.
function [int min1, int min2] = MIN_2_INT(int a, int b, int c)
int
max_a_b
int
min_a_b
if(a>b)
max_a_b = a
min_a_b = b
else
max_a_b = b
min_a_b = a
end
if
if(max_a_b
>
c)
min1 = min_a_b
min2
=
c
else
min1 = a
min2 = b
end
if
end function
This function, named MIN_2_INT, has three integer input arguments (a, b, c) and two
integer return arguments (min1, min2). Function body includes two declaration-
statements (local integer variables max_a_b and min_a_b) and two if-else statements.
The If function does not need to return arguments, it’s header does need to contain
any return argument. For example:
function foo()
// to do something’s
……
end function
This function does not return any values.
Maestro
Software Manual
MAXL Program Language
MAN-MASSW (Ver. Q)
5-32