Elmo HARSFEN0602 Network Hardware User Manual


 
HARSFEN0602
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
5.5.8 Break
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]) Loop until digital input2 is ON
if (!IB[1])
break; Break the loop when digital input 1 is OFF
end
MO=1; This command will be performed only after
digital inputs 1 or 2 are OFF.
5.6 Functions
5.6.1 Function 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.