× 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 11-Feb-2015 16:20 -0600, Pete Helgren wrote:
<<SNIP>> a simple RPGLE program which I can call from a command
line. The problem is that the parameter, which is a character type,
256 in length, gets padded with "unexpected" contents beyond what I
am submitting on the command line. If I submit it like so:

CALL PGM(MYPGM) PARM('This is a test')

I see something like this when I view the contents in either debug
or the receiving program:

'This is a testRPGLESRC MYLIBRAY MYPGM ??*SRCMBRTXT ‑ 1?' <<SNIP>>


If the parameter is declared as greater than 32-bytes, then pass every byte on the parameter; i.e. between the apostrophes, provide every byte, up to the length of the size declared for the parameter. Because typing all 256 bytes instead of just that short string of just 14 bytes would be a PITA, the better option is to define the interface to the command-line invocations, using a command definition. By ensuring the command parameter (PARM) data type declaration matches the parameter in the program, the CL command processor will pass the full 256 bytes as a character string padded with blanks.

The effect, the storage reserved for only up to 32 bytes for a literal as the argument passed, is irrespective of language used to define\declare the parameter in the invoked program.


<<SNIP>>

The program has these Prototypes/Procedure interfaces:

D mypgm pr extpgm('MYPGM')
D text 256A varying const options(*trim)

<<SNIP>>


The /varying/ declarative attribute indicates that the first two bytes of the string should be the length. Unfortunately, the only way on the command-line to pass the two-byte integer value is to use hex notation, which means the rest of the string must also be specified in hex notation because there is no support for expressions [like concatenation] at the command-line. So for example, the call using that prototype and the original example text could be accomplished via:

CALL PGM(MYPGM) PARM(x'000EE38889A24089A2408140A385A2A3')


I originally defined 'text' as 256A but saw the spurious characters.
So I tried options(*varsize), same result.

Using *VARSIZE, the implication is that the size is defined elsewhere; e.g. in an additional parameter.

So I tried varying const options(*trim). No joy ( get a variable out
of range error).

The first two bytes of the string passed in the example, the 'Th', are in hex the value X'E388'. The value x'E388' as a signed two-byte integer is a negative value. The varying-length length specification must not be a negative value, thus the value is not in the valid /range/ of allowed lengths.

<<SNIP>>

I want to pass a character string of up to 256 characters into this
program and only get the characters typed as the parameter value.
What am I missing?


Depends on the needs, but if the program must be invoked from a command-line, the best option is almost always to provide a *CMD definition as the interface to the user to invoke the program.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.