This wiki is out of date, use the continuation of this wiki instead

Loops

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 15:25, 1 May 2007 (edit)
FCR (Talk | contribs)

← Previous diff
Revision as of 15:26, 1 May 2007 (edit) (undo)
FCR (Talk | contribs)
m
Next diff →
Line 27: Line 27:
var2 = 0; var2 = 0;
repeat repeat
- var2++; //this does exactly the same but the check is at the end of the loop, thus this loop will be processed at least once!+ var2++; //this does exactly the same but the check is at the end of the loop,
 + //meaning this loop will be processed at least once!
until(var2 > 10) until(var2 > 10)
for(var3 = 0;var3 <= 10;var3++) for(var3 = 0;var3 <= 10;var3++)
- //this does exactly the same as the while loop but you control the incremention in the header of the loop which makes it more readable+ //this does exactly the same as the while loop but you control the incremention
 + //in the header of the loop which makes it more readable
end end
from var4 = 0 to 10 step 1 from var4 = 0 to 10 step 1

Revision as of 15:26, 1 May 2007


Definition

LOOP

Loop is a reserved word used to create iterations in your code. The terminator for a loop is end. the statements between these words will get repeated indefinately. There are several types of loops:

Example

Process loops()
Private
    var1 = 999;
    var2 = 999;
    var3 = 999;
    var4 = 999;
Begin
    var1 = 0;
    while(var1 <= 10)
        var1++; //this statement will be processed 10 times
    end
    var2 = 0;
    repeat
        var2++; //this does exactly the same but the check is at the end of the loop, 
                //meaning this loop will be processed at least once!
    until(var2 > 10)
    for(var3 = 0;var3 <= 10;var3++)
        //this does exactly the same as the while loop but you control the incremention 
        //in the header of the loop which makes it more readable
    end
    from var4 = 0 to 10 step 1
       //this does exactly the same as the while and the for loop. The '''step 1''' is optional
    end
    loop
        frame; //the frame statement will be processed forever
    end
End
Personal tools