× 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.



> The only thing that it changes is that both procedures can now have the
> same name.   If we do not have overloading support, you'd have to call
> them "getMonthNameFromDate" and "getMonthNameFromInt" because the names
> have to be unique.

To clarify what I'm saying further, I've written up a quick demonstration.
Of course, this will not compile since overloaded procedures are not part
of the current compiler, but it hopefully demonstrates what overloading
is.

I'd like to point out that you still have to define an explicit prototype
for each procedure, and explicitly define the data types of each parameter
in each procedure.  (In other words, overloading does NOT solve the
problem that Bob referred to here:
http://archive.midrange.com/rpg400-l/200310/msg00169.html )


     H DFTACTGRP(*NO)

      **
      ** Prototypes (these belong in a /copy member)
      **
     D getMonthName    PR            32A   varying overloaded
     D   MonthNo                     10I 0 value
     D getMonthName    PR            32A   varying overloaded
     D   DateFld                       D   const
     D getMonthName    PR            32A   varying overloaded
     D   TimeStmp                      Z   const
     D getMonthName    PR            32A   varying overloaded

     D name            s             50A
     D x               s             10I 0

      /free

          name = getMonthName();
          dsply name;

          name = getMonthName(%date() - %days(2));
          dsply name;

          name = getMonthName(%timestamp() + %days(1));
          dsply name;

          for x = 1 to 12;
             name = getMonthName(x);
             dsply name;
          endfor;

          *inlr = *on;

      /end-free

      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  getMonthName():  Retrieve the month name
      *
      *       MonthNo = month number (1-12) to get month from
      *
      *  Returns the month name or '' upon error
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P getMonthName    B
     D getMonthName    PI            32A   varying overloaded
     D   MonthNo                     10I 0 value

      /free
         select;
         when MonthNo = 1;
            return 'January';
         when MonthNo = 2;
            return 'February';
         when MonthNo = 3;
            return 'March';
         when MonthNo = 4;
            return 'April';
         when MonthNo = 5;
            return 'May';
         when MonthNo = 6;
            return 'June';
         when MonthNo = 7;
            return 'July';
         when MonthNo = 8;
            return 'August';
         when MonthNo = 9;
            return 'September';
         when MonthNo = 10;
            return 'October';
         when MonthNo = 11;
            return 'November';
         when MonthNo = 12;
            return 'December';
         other;
            return '';
         endsl;
      /end-free
     P                 E


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  getMonthName():  Retrieve the month name
      *
      *      DateFld = date field to get the month name from
      *
      *  Returns the month name or '' upon error
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P getMonthName    B
     D getMonthName    PI            32A   varying overloaded
     D   DateFld                       D   const
      /free
          monitor;
            return getMonthName(%subdt(DateFld: *MONTHS));
          on-error *all;
            return '';
          endmon;
      /end-free
     P                 E


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  getMonthName():  Retrieve the month name
      *
      *      TimeStmp = timestamp field to get the month name from
      *
      *  Returns the month name or '' upon error
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P getMonthName    B
     D getMonthName    PI            32A   varying overloaded
     D   TimeStmp                      Z   const
      /free
          monitor;
            return getMonthName(%subdt(TimeStmp: *MONTHS));
          on-error *all;
            return '';
          endmon;
      /end-free
     P                 E


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  getMonthName():  Retrieve the month name
      *
      *         No parameters -- uses the current date.
      *
      *  Returns the month name or '' upon error
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P getMonthName    B
     D getMonthName    PI            32A   varying overloaded
      /free
         return getMonthName(%date());
      /end-free
     P                 E



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.