09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

FOR i FROM 10 TO 2 STEP -1 DO<br />

a{i} := a{i-1};<br />

ENDFOR<br />

Program execution<br />

Limitations<br />

Syntax<br />

The values in an array are adjusted upwards so that a{10}:=a{9}, a{9}:=a{8} etc.<br />

1. The expressions for the start, end and step values are calculated.<br />

2. The loop counter is assigned the start value.<br />

3. The value of the loop counter is checked to see whether its value lies between the<br />

start and end value, or whether it is equal to the start or end value. If the value of the<br />

loop counter is outside of this range, the FOR loop stops and program execution continues<br />

with the instruction following ENDFOR.<br />

4. The instructions in the FOR loop are executed.<br />

5. The loop counter is incremented (or decremented) in accordance with the step value.<br />

6. The FOR loop is repeated, starting from point 3.<br />

The loop counter (of data type num) can only be accessed from within the FOR loop<br />

and consequently hides other data and routines that have the same name. It can only be<br />

read (not updated) by the instructions in the FOR loop.<br />

Decimal values for start, end or stop values, in combination with exact termination conditions<br />

for the FOR loop, cannot be used (undefined whether or not the last loop is running).<br />

(EBNF)<br />

FOR FROM TO <br />

[ STEP ] DO<br />

<br />

ENDFOR<br />

::= <br />

8-FOR-2 <strong>RAPID</strong> Reference Manual

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!