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



On Mon, 2014-09-29 at 02:32 -0500, Scott Klement wrote:
Alan,

You'd be correct if this was only being called from RPG. It's actually
the prototype in RPG that will do this for you, it will convert to
another data type. (And it doesn't have to be by value, it can be
either value or CONST reference)

However, that's not at all true when calling from CLLE -- which Mike
explicitly said that he wanted.

The CL compiler can't automatically change the data type of the
variable, because it doesn't know which data type the RPG procedure is
expecting... How could it, if there's no prototype to tell it what the
data type should be?!

However, there are ways to do what Mike is looking for, but they are not
quite as elegant.

1) You can use operational descriptors to find out the type of data
passed. Then, you can treat it accordingly (for example, you could use a
pointer to map the parameter to a variable with the appropriate data type.)

2) This is risky, but... a VARYING ("VarChar" is the SQL term) field
will have a 2 or 4 byte prefix containing the length. Bytes that make
up characters are almost always x'40' or higher. So for parameters with
a short max length, if the first byte is < x'40', then it's probably a
VARYING parameter, if it's x'40' or higher it's a fixed-length
character. Otherwise, it's a varying field.

I'm curious, how does it determine if it should be 2 or 4 bytes? Is it
based on the data type, ie DBCS, SBCS, etc also what is to stop a single
procedure being called by 2 programs with differing length of data (2v4)
bytes or does the prototyping prevent that so if it, the prototype,
knows it should be 4 bytes it enforces the caller to encode 4 bytes?




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.