9 break, 10 return, Break -20 – ElmoMC SimplIQ Software Manual User Manual

Page 49: Return -20

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-20

Example 2:
while 1

. . .

try

. . .

for k=0:5

if IB[16+k] == 1

break

end

if MS ! = 0

continue

end

MO=1;PA=0;BG

end

catch

. . .
end

end

If the condition MS ! = 0 is true, the program jumps to the beginning of the for loop and the
statements MO=1;PA=0;BG are not executed.

5.7.9

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. A break statement outside for, switch or while statements is illegal.

Example:

while (IB[2])

Loop while digital input 2 is ON.

if (!IB[1])

break;

Break the loop when digital input 1 is OFF.

end

end

MO=1;

This command will be performed only after digital input 1 or

2

is

OFF.

5.7.10 Return

The return command terminates the current function and returns control to the invoking
function. A called function normally transfers control to the function that invoked it when it
reaches the end of the function. A return may be inserted within the called function to force
an early termination and to transfer control to the invoking function. If the function was
called by an execute (XQ) command, a return command will close that program thread.
Closure of the main thread will close all other active threads.

Advertising