User Tools

Site Tools


rpg:random_number

Creating random numbers

 
      *---------------------------------------------------------------
      * Prototypes
      *---------------------------------------------------------------
     D CEERAN0         PR
     D   seed                        10I 0
     D   randomNumber                 8F
     D   feedback                    12A   options(*omit)
 
      *---------------------------------------------------------------
      * Variables
      *---------------------------------------------------------------
     D seed            S             10I 0 inz(0)
     D randomNumber    S              8F
     D max             S             10I 0 inz(10)
     D result          S             10I 0
     D i               S             10I 0
      /free
       for i = 0 to 10;
         CEERAN0(seed : randomNumber : *omit);
         result = %int(randomNumber * max) + 1;
         dsply %char(result);
       endfor;
 
       *inlr = *on;
       return;
      /end-free
rpg/random_number.txt · Last modified: 2013/06/20 07:00 (external edit)