|
|||||||
|
|
![]() |
|
|
|
|
||
|
Returning Qshell Data to OS/400 Hey, Ted: I have been trying to find a way to return a variable from within a Qshell script back to an OS/400 environment variable in a CL program, with no luck. Making a variable available to a Qshell session is no problem: I use Create Environment Variable (CRTENVVAR), and the value in that variable is now visible in my Qshell script. But when exiting the Qshell script, all external variables return to their original value. Of course, this is what you would expect under normal scoping rules. Is there a way to declare the environment variable in my CL as global? --Steven No. It is typical in Unix for a called routine not to be able to modify the arguments (parameters) that are passed to it. It reminds me of OCL procedures on the S/34 and S/36. We could pass arguments to a procedure, but the called procedure couldn't modify them in the caller. I suggest you stuff the values of variables into permanent objects, such as IFS files, database files, or data areas. There are plenty of ways to place data in IFS and database files from Qshell. Be sure to reference database files in IFS format. /qsys.lib/mylib.lib/myfile.file/mymbr.mbr To place data in a data area, you can use Qshell's system utility to execute CL commands. The following code creates a data area called NAME in library MYLIB and loads the value of Qshell variable name into it.
system "CRTDTAARA DTAARA(MYLIB/NAME) TYPE(*CHAR) LEN(48)"
system "CHGDTAARA MYLIB/NAME VALUE('$name')"
If you are at OS/400 V5R2, you can use Qshell's datarea utility. This utility is mentioned, but not explained, in IBM's Qshell manual. The following command writes the value of the name variable to data area NAME in library MYLIB. datarea -w /qsys.lib/mylib.lib/name.dtaara "$name" The value is placed in the data area beginning in position 1, and the remainder of the data area is cleared. To write to part of a data area, use the -s option, specifying the beginning and ending positions to be modified, separated by a hyphen (-). The following Qshell command places the value of the name variable in positions 7 through 44 of data area NAME in library MYLIB. datarea -w -s 7-44 /qsys.lib/mylib.lib/name.dtaara "$name" --Ted
|
Editors
Contact the Editors |
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |