Page 1 of 1

Repeat and For loop Usage

PostPosted: Mon Nov 22, 2010 11:56 am
by diptisaini
Hi,

I just need to know on what cases Repeat and For loop is used. Can you please explain me with some examples?

Thanks

Re: Repeat and For loop Usage

PostPosted: Mon Nov 22, 2010 11:57 pm
by RGZbrog
FOR is used typically to process an array. The syntax allows a starting value, ending value, and increment of an index variable.

REPEAT can be used to execute a block of code UNTIL or WHILE a condition exists, but more often it is used as an infinite loop in which the on-line user determines when to exit by pressing a specific PF key.

Re: Repeat and For loop Usage

PostPosted: Fri Dec 17, 2010 6:51 pm
by fidelis
The FOR statement is just used to initiate a processing loop and to control the number of times the loop is processed. The REPEAT statement is used to initiate a processing loop uncontrolled to number of times the loop is processed, but you can use UNTIL that will process loop until the logical condition becomes true, or can use WHILE that will process loop continued as long as the logical condition is true.