ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

make parms optional in RPG

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • make parms optional in RPG

    Copy the source below and "play" with it passing or not passing parms....

    Code:
          *
         d Display         s             30
         d reply           s              1
         d count           s              1  0
          *
         d Inparm1         s             15  5
         d Inparm2         s             10
         d Inparm3         s              2
         d Inparm4         s             15  5
          *
         d WorkParm1       s              3  0
         d WorkParm2       s             10
         d WorkParm3       s              2
         d WorkParm4       s              8  0
    
          *
         c     *entry        plist
         c                   parm                    Inparm1
         c                   parm                    Inparm2
         c                   parm                    Inparm3
         c                   parm                    Inparm4
          *
         c                   if        %parms >= 1
         c                   eval      WorkParm1 = InParm1
         c                   endif
          *
         c                   if        %parms >= 2
         c                   eval      WorkParm2 = InParm2
         c                   endif
          *
         c                   if        %parms >= 3
         c                   eval      WorkParm3 = InParm3
         c                   endif
          *
         c                   if        %parms >= 4
         c                   eval      WorkParm4 = InParm4
         c                   endif
          *
         c                   for       count = 1 to 4
          *
         c                   select
         c                   when      count = 1
         c                   eval      display = %char(WorkParm1)
         c                   when      count = 2
         c                   eval      display = WorkParm2
         c                   when      count = 3
         c                   eval      display = WorkParm3
         c                   when      count = 4
         c                   eval      display = %char(WorkParm4)
          *
         c                   endsl
          *
         c     display       dsply     reply
         c                   endfor
          *
         c                   eval      *inlr = *on
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com
Working...
X