8 functions, 1 function declaration, 8 functions -22 – ElmoMC SimplIQ Software Manual User Manual

Page 51: Function declaration -22

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-22

5.8

Functions

Functions are program sections that can be defined by parameters and called from
anywhere in the program.

5.8.1

Function Declaration

A function declaration consists of the following parts:
ƒ

Reserved function keyword

ƒ

List of output arguments with their types in brackets (optional)

ƒ

Assignment sign, only if there is an output argument

ƒ

Function name

ƒ

List of input arguments with their types in parentheses (list of input arguments can be
empty)

ƒ

Reserved return keyword that closed the function scope

Example 1:
function [int y1, int y2] = func1 (float x1, int x2)
A function named func1 has two input arguments — x1 and x2 — and returns two output
arguments.

The list of output arguments may be empty. In this case, two and three items are absent, or
the brackets can be empty. If there is only an output argument, it can be without brackets.
The maximum admissible number of input and output arguments is 16.

Example 2:
function func2 (float x1)
A function named func2 has a single input argument of float type and returns no output.

Example 3:
[int y1] = func3 (int x1)
This function declaration is illegal because the function keyword is missing.

Example 4:
function y1 = func5
This function prototype is illegal because the type of output variable is missing

The valid function name follows the same rules as the variable name. It must be distinct
from any variable, function or label name. The definition of dimensions of the output and
input arguments at the function declaration is illegal.

Example 5:
function [int x[100]] = func3 ()
This function declaration is illegal because the dimension of the output argument is defined

A function may have a prototype before its declaration. The prototype has the same syntax
as the function declaration, but it must end with a semicolon.

Advertising