Ü  FOR (For loop)

§  The For loop in RPGLE seems similar to a ‘FOR’ loop in any other programming languages.

§  The initial counter, the final counter and the increment value. The counter of the loop begins from 1 and is incremented/decremented by the step(2) till the counter becomes greater than (or less than) the max value(6).

Factor 1

Op-code

Extended Factor 2

FOR

Index variable = initial counter BY increment TO final counter

 

Example


DCount          S              2P 0 Inz(2)
**
C                   For       Count = 1 to 6 by 2
C     Count       Dsply
C                   EndFor
**
C                   Return

 

                   

 

OUTPUT

 

DSPLY   1

DSPLY   3

DSPLY   5

 










User Comments:



Subscribe

  Email:



Copyright © www.go4as400.com, 2013-2017. Copyright notice