2 repeat process, While sentence, For sentence – KEYENCE SR-700 Series User Manual

Page 9: Repeat until sentence, Break sentence, Repeat process, Format for sentence, Format, Format break sentence

Advertising
background image

9

E SR SCRIPT RM

4-2

Repeat process

This section describes processes when repeating processes.

while sentence

while sentences perform repeat process by specifying continuation conditions.

Format

for sentence

for sentences repeat process using the counter to count the number of repetitions.

Format

z

Base

z

Specifying "increment of counter"

while

continuation

condition

do

As long as the continuation condition is fulfilled, the process is
repeated.
If the continuation condition is not fulfilled, the repeat process
ends.

Process

end

Example

while

(i<=10)

do

If i is 10 or less, the value for i is increased by one.

i = i+1

end

for

Initialization expression for counter,

and final value

do

• Sets the default value to the counter

(variable). The process is repeated until
the value exceeds the final value.

• Each time the process ends, the counter

increases by one.

Process

end

for

Initialization expression for counter, final value

and increment of counter

do

• Sets the default value to the counter

(variable). The process is repeated until
the value exceeds the final value.

• Each time the process ends, the counter

increases by positive and negative integer
value specified.

Process

end

Example

for

i=1,5

do

If i is 5 or less, the value for a is increased by two.

a=a+2

end

Continuation condition

Process

Yes

No

Final value of counter >= counter

Initialization of

Yes

No

Process

Addition of counter

repeat until sentence

repeat until sentences execute process at least once. After the last condition is
checked, whether to repeat is judged.

Format

break sentence

Use break when going out in the middle of repeat process of while sentences or of
for sentences.

Format

* break can be written only just before end.

To call break in the middle of the sentence, write as below.

repeat

• After the process is executed once, the process is repeated

until the condition is fulfilled.

Process

until

condition

Example

repeat

Regardless of the i value, the value for a is increased by two,
and the value for i is increased by one.
If i is 10 or less, the value for a is increased by two.

a=a+2

i = i+1

until

(i<=10)

while continuation
condition do

Conditional expression

Process

break

end

end

Example

do

break

end

Continuation condition

Process

Yes

No

No

Conditional expression

Advertising
This manual is related to the following products: