Repetition

There is one, at first glance rather huge construct, which serves to express repetitions. Its purpose is to repeat a paragraph under various circumstances.

(315,300) (000,290)repetition (000,270)(1,0)030040FOR (1,0)030060variable-name (1,0)005 (005,260)(20,20)[rt] (015,260)(0,-1)160 (165,260)(20,20)[r] (165,250)(-1,0)140 (025,240)(20,20)[l] (025,230)(1,0)005040FROM (1,0)030060expression (1,0)005 (165,220)(20,20)[r] (165,210)(-1,0)140 (025,200)(20,20)[l] (025,190)(1,0)005040UPTO (1,0)030060expression (1,0)005 (165,180)(20,20)[rt] (175,180)(0,-1)020 (025,180)(20,20)[lb] (025,170)(1,0)005040DOWNTO (1,0)030060expression (1,0)005 (165,160)(20,20)[r] (165,150)(-1,0)140 (025,140)(20,20)[l] (025,130)(1,0)005040WHILE (1,0)030060expression (1,0)005 (165,120)(20,20)[r] (165,110)(-1,0)140 (025,100)(20,20)[l] (025,090)(1,0)005040REP (1,0)030060paragraph (1,0)005 (165,080)(20,20)[r] (165,070)(-1,0)140 (025,060)(20,20)[l] (015,060)(0,-1)040 (025,050)(1,0)005040UNTIL (1,0)030060expression (1,0)005 (165,040)(20,20)[r] (165,030)(-1,0)140 (025,020)(20,20)[l] (025,010)(1,0)005040ENDREP (1,0)120

Since many of its constituents are optional, it can be tuned to different applications.

The expressions after WHILE and UNTIL are conditions, and therefore have to be boolean. The other expressions, as well as the variable after FOR (controlled variable) have to be integer. The repetition does not yield a value as result (it is an action).

The semantics of the repetition is quite conventional. The for-part can be omitted if the controlled variable does not occur in the body of the repetition. The constituents FROM 1, UPTO maxint, DOWNTO minint, WHILE true and UNTIL false can be omitted (i.e. are assumed if the corresponding constituents is omitted).