Instruction that allows subprograms to be declared that can be called from anywhere in the user program.
The use of functions allows those instructions that must be executed repeatedly to be grouped into a single portion of code, with the aim of reducing memory occupancy and improving program clarity.
Simple function
Syntax |
function name () .... Subprogram Instruction ... end_fun |
---|---|
name |
This is the identifier of the function and follows the normal rules that apply to variable names |
Validity |
Rule, Task |
Note |
Use instruction call to call the function |
Function with parameter passing
Syntax |
function [type] name ([par1][, parN]) .... Subprogram instruction ... [return value ] ; (only if return value present) end_fun |
---|---|
type |
It is the eventual keyword i32 or real that defines the type of the parameter to be passed or the type of the return value. (optional) |
name |
It is the identifier of the function and follows the normal rules that apply to variable names |
par1 |
It is the value of the first parameter passed to the function |
parN |
It is the eventual value of the n-th parameter passed to the function. (optional) |
Validity |
Rule, Task |
Note |
Use instruction call to call the function. When the function has no incoming parameter, brackets used for parameter delimitation may be omitted. In the case of passing a real value to a function where a parameter of type integer has been declared, there will be an automatic type conversion, from real to integer, without error reporting. Since RC3E 33.01.08, the passing of array-type parameters to functions (arrays of int, real, and structures) has been added. Structures passed to a function are always passed as references. From RC3E 33.01.21 it is possible to pass RPE objects: (type Axes_Group, Point_l, Point_c, Point_j, Path, Transform) |
Example of use:
Example of use:
Example of use:
|