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



Well thanks for all that, Scott and Chris. I really did not notice that
the link was related to C/C++ (good to know though).

I have always asked about the fact that, for example, if your RPG parameter
in your called program is longer than the actual bytes that you write as
that parameter when CALLing it, very often I get, within my program,
garbage at the end of the parameter if I don't fill it out completely with,
say, blanks.

I guess that, like most OSes, the IBM i OS assumes parameters in a memory
space that's in the processor's stack pointer, and that area of memory is
very likely to have garbage before the OS actually writes your bytes to the
parameter value. I was having a bad time today because my text parameter
was not being %TRIMMED() to the actual size, and when I inspected it very
carefully, it was when I realized that there was garbage at the tail of it.

This is too bad. I think that the area of the stack pointer that points to
your parameter should be cleared out before, so you actually have what you
typed in on the command line.
I don't know why that happens. When debugging, I can see my actual data
then some spaces and then some known previous data like 'QCMD' and it is
that the stack kept that data.

Thanks a lot.

Javier.

El vie, 29 abr 2022 a las 13:01, Scott Klement (<midrange-l@xxxxxxxxxxxxxxxx>)
escribió:

Javier,

The link you posted is to the ILE C/C++ Programmer's Guide. And indeed,
for ILE C/C++ it does add the x'00' automatically to the end of the
parameter.

It does not for RPG, however. You'd have to add it yourself.

One way is to write your own command. In the CPP do something like

DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')

CHGVAR (&OUTPARM) VALUE(&INPARM *TCAT &NULL)

CALL THEPGM PARM(&OUTPARM)

Or better yet create the command so that it prefixes the character
parameter with its length, which is more RPG-like.

-SK


On 4/29/2022 12:50 PM, Javier Sanchez wrote:
Hi folks:

How do you append a hex 00 byte to a text/char command line parameter?

Example:

CALL MYLIB/MYPROG PARM('My Text/Char parameter' + X'00)

The latter does not work because the plus sign would obviously be taken
as
the second parameter and just then the X'00' would be taken as the third
parameter. Of course that is not what I want.

According to IBM, below, it says that I don't need to do that because the
system automatically appends a hex 00 to the text parameter. Please
check
out this link:


https://www.ibm.com/docs/en/i/7.3?topic=command-call-call-parameter-conversions

But I wrote a small RPG program to test for a hex 00 byte and it doesn't
really do it.

My test program expects a 64-byte single parameter. Then I call it like
this:

CALL MYLIB/MYPGM('my small text parm')

Then within my program, a test for a hex 00 like:

nullBytePos = %SCAN(X'00': text_param);

And it returns zero. What is wrong then?

TIA.

Javier.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx 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 ...

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.