× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Christopher,

> I have a program that takes 2 parameters, a start date and a end date. I
> would like to make it so that the program can check and see how many
> parameters are passed. If 2 parameters are passed then use those as the
> start and end date. If no parameters are passed, then use some defaults.
> I am using RPG ILE and freeform syntax.

Here's some sample code that gets two parms... they are packed numbers,
8,0, intended to be dates in YYYYMMDD format.  When they are not passed,
the start date defaults to the start of the year, the end date defaults to
the end of the year.

     H OPTION(*SRCSTMT)

     D MyPgm           PR                  ExtPgm('MYPGM')
     D   peStartDate                  8P 0 const options(*nopass)
     D   peEndDate                    8P 0 const options(*nopass)

     D MyPgm           PI
     D   peStartDate                  8P 0 const options(*nopass)
     D   peEndDate                    8P 0 const options(*nopass)

     D StartDate       s               D
     D EndDate         s               D
     D Temp            s             10A

      /free

         // Use start date if passed, otherwise use start of year.

           if ( %parms() >= 1 );
              StartDate = %date(peStartDate: *ISO);
           else;
              Temp = %char(*YEAR) + '-01-01';
              StartDate = %date(Temp: *ISO);
           endif;

         // Use end date if passed, otherwise use end of year.

           if ( %parms() >= 2 );
              EndDate = %date(peEndDate: *ISO);
           else;
              Temp = %char(*YEAR) + '-12-31';
              EndDate = %date(Temp: *ISO);
           endif;

         // Now run the report for those dates:

           RunMyReport(StartDate: EndDate);

           return;
      /end-free


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.