Elmo HARmonica, HARSFEN0602 software manual Break, Functions Function definition, Syntax break

Models: HARmonica HARSFEN0602

1 220
Download 220 pages 51.63 Kb
Page 42
Image 42

HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

 

 

 

 

 

switch (k)

For example, k=2

 

 

case 1

 

 

 

PA=1000;

 

 

 

case 2

 

 

 

PA=2000;

This statement will be performed

 

 

otherwise

 

 

 

PA=500;

If k doesn’t equal to 1 or 2 , pa=500

 

 

end

 

 

 

 

 

 

40

5.5.8Break

Syntax: break

The break statement terminates the execution of the nearest enclosing for, switch or while statement in which it appears. Control passes to the statement that follows the terminated statement. The break statement is outside of for, switch or while statements is illegal.

Example:

while (IB[2])

if (!IB[1])

break;

end

MO=1;

Loop until digital input2 is ON

Break the loop when digital input 1 is OFF

This command will be performed only after digital inputs 1 or 2 are OFF.

5.6Functions

5.6.1Function definition

Functions are program sections that can be parameterized and called from anywhere in the program. Function declaration consists of the following parts:

1.Reserved keyword function

2.List of output arguments with their types in square brackets– optional

3.Assignment sign – only if there is some output argument

4.Function name

5.List of input arguments with their types in round brackets. List of input arguments may be empty.

For example,

1 function [int y1, int y2] = func1 (float x1, int x2) This function is named func1, it gets two input arguments x1 and x2 and returns two output arguments

List of output argument may be empty. In this case 2 and 3items are absent or it can be empty square brackets. If there is the only output argument it can be without square brackets.

Maximal admissible number of input and output arguments is 16.

Page 42
Image 42
Elmo HARmonica, HARSFEN0602 software manual Break, Functions Function definition, Syntax break