20.07.2014 Views

DOC1 Programmer's Guide

DOC1 Programmer's Guide

DOC1 Programmer's Guide

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.

Programming PCE<br />

for…next<br />

Function. Indicates script statements that are to be processed repeatedly a fixed number of times.<br />

Syntax. for [counter =] start to end ;<br />

...<br />

next;<br />

Parameters counter a variable to hold the loop counter<br />

start<br />

integer; the base number of the loop counter when it is first processed<br />

end<br />

integer; the number of the loop counter when processing is to end.<br />

Effects<br />

Statements between the for and next commands will be executed the number of times<br />

indicated by the difference between start and end. For example, 1 to 5 will execute the loop<br />

five times; 3 to 4 will execute the loop twice.<br />

The current sequence number within the start/end range is used to update counter at the start<br />

of each pass.<br />

Comments If coded, the contents of the counter variable may be referenced within the loop. It can be<br />

omitted unless you want to nest for…next loops in which case each must be assigned to a<br />

different variable.<br />

Example for = 1 to 4;<br />

// Get file name for th output file<br />

// convert numeric to string and append to base file name<br />

let = STRING ;<br />

let = + ;<br />

// open th file<br />

open for output as file LINE / PLAIN;<br />

// read fields from next input file record<br />

let = 7;<br />

read items from file 0 into ;<br />

// NOTE: arrays are indexed from 0<br />

let = - 1;<br />

for = 0 to ;<br />

// Output fields read from th record of input file<br />

// as separate records in the th output file<br />

write 1 item into file from ();<br />

next; // <br />

next; // <br />

46

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

Saved successfully!

Ooh no, something went wrong!