2 dummy variables, 3 count of output variables, Dummy variables -24 – ElmoMC SimplIQ Software Manual User Manual

Page 53: Count of output variables -24

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-24

y2 = y1 + y2 ;

Executable code

Return

Function end

Before a function call, the function must be declared, either as a function prototype or a
function definition.

Example 13:
function [int y1, int y2] = func (float x1, int x2;)

Function prototype


function main ()

Function main definition

int a, b;

Local variable definition

[a,b] = func (2.3, -9.0);

Function call

Return

Function main end


function [int y1, int y2] = func (float x1, int x2)

Function definition

… Function

body

Return

Function end

If a function is declared without a body, its call is illegal.

Example 14:
function [int y1, int y2] = func (float x1, int x2) ;

Function prototype


function main ()

Function main definition

int a, b;

Local variable definition

[a,b] = func (2.3, -9.0);

Function call

Return

Function main end

In this example, function func has a prototype, but no body, so its call is illegal.

5.8.2

Dummy Variables

The input and output arguments of a function are called dummy variables. A true variable
is substituted for the dummy variable when a function is called.

Example:
function [float mean, float std]=statistic();

In this function, variables mean and std are dummy variables (full example in

section

5.8.3

).

5.8.3

Count of Output Variables

A function may return multiple values, although in certain cases, not all outputs need be
computed. The nargout keyword can therefore be used to indicate which of the results
actually need to be evaluated.

The number of outputs is the number of items in the left side of the expression during the
function call. If this number exceeds the maximum number of defined output arguments for
the function, or the maximum admissible number of output arguments, an error will be
declared.

Advertising