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



Rob,

I think you know this, but aren't thinking about it.. a parameter is passed by "reference", which means that what's actually passed under the covers is a pointer.

When you do this:

CHGLIBL LIBL(&ONE &TWO &THREE &FOUR &FIVE)

It's passing 5 pointers. They point to variables named 'ONE', 'TWO', 'THREE', 'FOUR', and 'FIVE'. Five different pointers. Their strings might not be stored consecutively in memory, either.

On the other hand, when you do this:

CHGLIBL LIBL(&USRLIBL)

You are passing only one pointer -- and therefore only one parameter. What's happening under the covers is VERY different from the earlier example.

The system doesn't know that you mean to specify a whole list of libraries in this case... it thinks, since you only passed one parameter, that you have only one library. And then it thinks you made a mistake by passing such a large string, because libraries can only be 10 characters long, after all. :-) That's just the way the computer "thinks".

One way to work around this is to call an API like QCMDEXC. This API receives the entire command line as a single string and then has to parse it out to get the individual parameter values. That's the sort of thing you're trying to do...


DCL VAR(&CMD) TYPE(*CHAR) LEN(3000)

CHGVAR VAR(&CMD)
VALUE('CHGLIBL LIBL(' *CAT &USRLIBL *TCAT ')')
CALL PGM(QCMDEXC) PARM(&CMD 3000)

For this to work, there must be at least one blank in between the libraries in the list... If not, you might have to do a little manipulation to get some spaces in there.


On 6/18/2013 11:15 AM, rob@xxxxxxxxx wrote:
I have this simple little test program:
PGM
DCL &JOBLIBL *CHAR 2750 /* User part of library list */
DCL &USRLIBL *CHAR 250 /* User part of library list */

DSPJOB OUTPUT(*PRINT)
RTVJOBA USRLIBL(&JOBLIBL)
RTVSYSVAL SYSVAL(QUSRLIBL) RTNVAR(&USRLIBL)
CHGLIBL LIBL(&USRLIBL) CURLIB(*SAME) /* 1209 */
DSPJOB OUTPUT(*PRINT)
CHGLIBL LIBL(&JOBLIBL) CURLIB(*SAME) /* 1211 */
DSPJOB OUTPUT(*PRINT)

END:
ENDPGM

CALL A
Value 'QTEMP ' for parameter LIBL not a valid name.
Error found on CHGLIBL command.
Function check. CPF0001 unmonitored by A at statement 1209, instruction
X'0023'.
CPF0001 received by A at 1209. (C D I R)
? I
Value 'QTEMP ' for parameter LIBL not a valid name.
Error found on CHGLIBL command.
Function check. CPF0001 unmonitored by A at statement 1211, instruction
X'002F'.
CPF0001 received by A at 1211. (C D I R)
? D

Results of dump:

Variable Type Length Value
*...+....1....+....2....+
&JOBLIBL *CHAR 2750 'QTEMP QGPL '
+26 ' '
+51 ' '
...
&USRLIBL *CHAR 250 'QTEMP QGPL '
+26 ' '
+51 ' '
...


Rob Berendt


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.