|
On Thu, 7 Nov 2002, Haas, Matt wrote:
>
> A better way would be to create a data structure for these two values
> and return the data structure just like you would when dealing with
> API's. This makes the program much easier to maintain if you need to
> return another field in the future.
>
I disagree with this statement. There are cases when returning a data
structure is a good technique, but not for a simple 'CVTA2N' subprocedure.
Using a data structure makes for much less elegant code wherever this
subprocedure is called. While that might be necessary for a complex
subprocedure, for something this simple it just adds complexity.
Instead, I'd do this:
D CVTA2N PR 30P 9
D ACGAMT 32A const
D ERRORS 30A options(*nopass)
The optional parameter would be for reporting error information if
the convert fails, but the programmer may not always care about that,
so, I made it optional.
Since the return value is passed by value, you can assign it to any
numeric variable, eliminating the need to add code to convert it to
zoned/packed/longer/shorter/more decimals/less decimals, etc.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.