× 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 Wynn,

I think, that the behavior is of course documented.

https://www.ibm.com/docs/en/i/7.3?topic=codes-eval-evaluate-expression#zzeval

A "=" assignment is implicitly an EVAL operation.

So when assigning a varchar value to a char variable, EVAL does indeed an implicit typecast, assigns the value left justified and pads it with spaces on the right. It does also typecast the other way around.

That the varchar "value" is the return value of a procedure, doesn't matter - a "right hand value" is a value - no matter where it comes from.

HTH
Daniel


Am 20.07.2023 um 15:06 schrieb Osborne, Wynn <Wynn.Osborne@xxxxxxxxxxxxxxxxxx>:

Hi all,

Does RPG implicitly cast a varchar return value (from a procedure) to char when the receiver variable is char?

Sample random code (2 lines):

dcl-s CharacterVariable char(50) inz(' '); //character date type
CharacterVariable = EmailAddress ( 'Bob Saget' ); //EmailAddress has return value defined as varchar(50).

Although this appears to work for some of my teammates I was told by Bruce Vining (remember Bruce??) that if IBM does not explicitly document a behavior then one should never assume it to be true "just because it works for you." (paraphrasing Bruce).
I believe his exact words were, "Bad things can happen." :)

I was thinking of instructing my team to make this practice verboten, but I thought I'd ask the list first.

Unless I'm blind I could find no text in the RPG Reference to address this, much less come close to implying it.

Regards,


[cid:image001.png@01D9BAE8.13979320]
Wynn Osborne
Senior IBM i Programmer-Analyst,Database Administrator
6503 Powell Road | The Villages, FL 32163
Main: 352.750.1515 | Support: 352.674.1530
Direct: 352.674.1563 | Fax: 352.750.1616
wynn.osborne@xxxxxxxxxxxxxxxxxx<mailto:wynn.osborne@xxxxxxxxxxxxxxxxxx> | http://www.TheVillagesTSG.com<http://www.thevillagestsg.com/>


--
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@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.


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.