2 for iteration, For iteration -14 – ElmoMC SimplIQ Software Manual User Manual

Page 43

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-14

Example 1:
##START;

Start

program.

##LOOP1;

Label

… Body

code

A

Goto##LOOP1;

##LOOP2;

Body code B

##LOOP3;

According to this example, if the program runs from label ##START, body code A will be
performed forever. ##LOOP2 will never be reached.

Example 2:

#@WAIT_POWER:

Subroutine

definition

wait 3000

subroutine body - wait 3 sec

return

End

subroutine


WAIT_POWER

Call

subroutine


reset WAIT_POWER;

Kill stack and call subroutine

In this example, the subroutine WAIT_POWER is called explicitly the first time and is used as
the target for a reset instruction the second time.

5.7.2

For Iteration

This performs an indexed iteration in a program.

Syntax:
for k=N1:N2:N3


end

Iterates

k

from N1 to N3 with a step of N2.

or

k=N1:N2


end

Iterates k from N1 to N2 with a step of 1.

In both cases, N1, N2 and N3 are numbers or simple expressions.

Notes:

ƒ

If the iteration step is zero, the program is aborted with the error code
INFINITE_LOOP.

ƒ

If N1, N2 or N3 is a variable, it is evaluated once before the iteration begins. If the
variable changes within the “for” loop, the iteration process is not affected.

Advertising