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



I don't think you understood what I was asking.

I do understand that the return value isn't needed when calling a program or any other prototype that doesn't return a value.

However, the example has this:

    DCL-PR format VARCHAR(100)
                               OVERLOAD(format_time : format_date : format_message);

Why does she specify VARCHAR(100) here?  Seems like this should not be allowed.  It should always infer the return value from the candidate prototypes.

-SK


On 10/8/2019 1:05 PM, Jon Paris wrote:
It doesn't Scott. If it did you couldn't overload to a program.

IF there is a return value it must be the same for all of the overloaded procedures.



On Oct 8, 2019, at 10:34 AM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:

Yeah, it mostly makes sense to me. The one thing that seems weird is the need for a return value on the prototype with the OVERLOAD keyword (i.e. the "candidate prototype") Since all of the prototypes have to have the same return value (I think?) and the candidate prototype doesn't need parameters coded, why does it have a return value coded? That's weird to me.


On 10/8/2019 12:32 PM, Vernon Hamberg wrote:
No need to presume - look at the article - it's pretty simple and elegant, as Barbara usually does things.


*Overloaded prototypes*

The OVERLOAD keyword defines a list of other prototypes that can be called using the name of the prototype with the OVERLOAD keyword. When the prototype with the OVERLOAD keyword is used in a call operation, the compiler uses the parameters specified for the call to determine which of the candidate prototypes listed in the OVERLOAD keyword to call.

In the following example, FORMAT is defined with the OVERLOAD keyword. For the first call to FORMAT, the parameter has type Date, so FORMAT_DATE is called. For the second call to FORMAT, the parameter has type Time, so FORMAT_TIME is called. For the second call to FORMAT, the parameters have type Character, so FORMAT_MESSAGE is called.

DCL-PR format_date VARCHAR(100);
dateParm DATE(*ISO) CONST;
END-PR;
DCL-PR format_time VARCHAR(100);
timeParm TIME(*ISO) CONST;
END-PR;
DCL-PR format_message VARCHAR(100);
msgid CHAR(7) CONST;
replacement_text VARCHAR(100) CONST OPTIONS(*NOPASS);
END-PR;
DCL-PR format VARCHAR(100) OVERLOAD(format_time : format_date :
format_message);
DCL-S result varchar(50);

result = format(%date()); // 1
result = format(%time()); // 2
result = format('MSG0100' : filename); // 3



On 10/8/2019 12:11 PM, Justin Taylor wrote:
OVERLOAD!!!

Presumably, the overload will be a prototype only without a procedure. How will that work with exported procedures?

I assume you'll still be able to call the real procedures directly. That would be less than ideal, but understandable.




-----Original Message-----
From: Jon Paris [mailto:jon.paris@xxxxxxxxxxxxxx]
Sent: Tuesday, October 08, 2019 11:46 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Latest RPG Updates

I see Barbara has posted this elsewhere but I know of many on this list who have been waiting for procedure overloading. Yay! It is here ands I love it!

Also (although not quite as requested) we now have "XML-FROM" in the form of DATA-GEN which is kind of Open Access meets DATA-INTO (but backwards). You'll have to wait for meaningful examples of this one but I'll be putting out an article on procedure overloading in a couple fo weeks.

Link to the basic details is here: http://ibm.biz/fall_2019_rpg_enhancements <http://ibm.biz/fall_2019_rpg_enhancements>


Jon Paris
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.