REXX Tips & Tricks:Troubleshooting
his section contains hints for some REXX errors, symptoms, and messages. Note that a lot of hints in this section are captured from CompuServe messages.
In addition to the tips mentioned below I suggest everyone having problems with REXX programs should get the new Object-Oriented REXX. Object-Oriented REXX has much more descriptive error messages and the documentation is better than the normal REXX online documentation.
Another good source for Troubleshooting information is the Common REXX Pitfalls page on the home page of Quercus Systems (see Internet - Web Pages)
Note that the information related to various APARs is included in the sections General hints for REXX, REXXUTIL functions and Change the WPS with REXX. See those sections for additionan information.
Here's a list of further sections in REXX Tips & Tricks with information about various errors:
Errors in OS/2 commands http://www.edm2.com/index.php/
- CTRL-Break &OS/2 commands
- STDOUT / STDERR
- Using PIPEs
- The CMD command
- The COPY command
- Copying empty files
- The XCOPY command
General REXX Errors
Object REXX Errors
- The function CHARS() in Object REXX
- The function LINEOUT() in Object REXX
- The function LINES() in Object REXX
- The function STREAM() in Object REXX
- The function VALUE() in Object REXX
- The Signal handling in Object REXX
Errors in REXXUTIL functions
- The function SysCopyObject()
- The function SysCreateObject()
- The function SysFileSearch()
- The function SysIni()
- The function SysQueryClassList()
- The function SysSearchPath()
WPS related Errors
- Format of the RC files for MAKEINI
- Creating shadows of drive objects
- Changing the LaunchPad
- WPS Object Setup strings (and the sub sections)
No light, no sound
Problem: The call of a REXX program neither produces the expected result nor an error message.
Hint: Check if the file REX.MSG (normally in the directory C:\OS2\SYSTEM) is in a directory included in the environment variable DPATH. This file contains the error messages for the REXX Interpreter.
RC = 1041 or RC = 1002
Problem: The call of an OS/2 program leads to the error code SYS1041 or SYS1002, although the called OS/2 program is available through the environment variable PATH.
Hint: Check the value of the environment variable COMSPEC.
It runs, runs not, runs, runs not, ...
Problem: A REXX program works sometimes and sometimes not.
Hint: If the program uses file I/O, check if you're closing all opened files. The number of file handles is limited in an OS/2 session. (see MaxFH on how to increase the number of file handles; see lsof for getting a list of all open files)
Please note that the entry FILES=nn in the file CONFIG.SYS is only valid for DOS sessions!
What the hell is he doing?
Problem: The results of a REXX program aren't as expected.
Hint: Turn the NOVALUE condition on. (see SIGNAL)
Haeaeh -- Syntax error?
Problem: The execution of a REXX program leads to mysterious syntax errors.
Hint: Check the file for unbalanced comment chars. A simple way to do that is: Use the find-and-replace-function of your editor to replace the string "/*" with "/*" and the string "*/" with "*/". The number of changes for both calls should be equal. If not, there's an unbalanced comment in your file.
Another method to detect unbalanced comment chars: Use an editor with syntax highlighting.
See also: Using comments
2 + 2 = 5
Problem: The results of mathematical expressions aren't as expected.
Hint: Change the NUMERIC settings to a greater value.
DLL loading failed
Problem: The call of �RxFuncAdd failed although the DLL to load is accessible through the �LIBPATH.
Hint: For some DLLs the name of the DLL function to register (this is the third parameter for �RxFuncAdd) is case-sensitive! This depends on how the DLL was linked.
Use an ExeHdr tool or take a look at the DLL with a Hex-viewer to get the proper spelling for the name of the register function.
Another cause for this error:
- Maybe the DLL needs some other DLLs - these DLLs must also be accessible through the �LIBPATH.
- To check which other DLLs the DLL need, you can use the excellent program PMDLL. or IBM's chkdll32.exe.
See also: The REXX API functions
SYS1801
Problem: The execution of a REXX program leads to the error �SYS1801 although REXX support is installed.
Hint: Maybe the EAs are corrupted. Try a CHKDSK /F on the drive where the REXX program resides.
REX0003: Program is unreadable
Problem: Calling a REXX cmd leads to the error message Program is unreadable.
Hint: This error is generated if a CMD-file called with the �CALL statement is locked or deleted by another process. You'll get this error also if the function name for a �CALL statement is a directory name or a device name (e.g. call con, see Reserved directory & file names). The above is also true for function calls. (see also REXX programs without an extension and Error: Failure during initialization)
1 +++ @REXX g + ? OS / 2 REXXSAA 6.00 12 Jul 1995
Problem: The call of a REXX cmd leads to an error message like 1 +++ @REXX g + ? OS / 2 REXXSAA 6.00 12 Jul 1995 ( P ? + õ? ?? REX0013: Error 13 running E:\DATEN\DFUE\DOWNLOAD\TEST\OREXXTRY.CMD, line 1: Invalid character in program
Hint: You tried to run a tokenized Object-Oriented REXX program under the normal REXX interpreter. You need Object-Oriented REXX to run this program (see also "Compiling" REXX programs and Error: Failure during initialization)
Error: Failure during initialization
Problem: The call of an EXE program containing REXX code leads to the error message REX0003E: Error 3: Failure during initialization REX0200E: Error 3.1: Failure during initialization: File "%1" is unreadable
Hint: You tried to run a tokenized Classic REXX program under Object-Oriented REXX. Object-Oriented REXX cannot execute token images of REXX programs created with Classic REXX. EXEs with token images are created by some of the GUI environments for REXX or by RxCLS - a REXX 'compiler' ($). You may try to load the Classic REXX interpreter prior to calling the REXX program causing this error (see Using Classic REXX if Object REXX is the default REXX; see also REX0003: Program is unreadable)
SYS0008
Problem: There seems to be a bug in REXX which leads to the error �SYS0008 if you repeatedly call an OS/2 command in a REXX program. (see the Example for the SYS0008 error)
Hint: To avoid this problem use equivalent REXX functions where possible. If there's no such REXX function, you can create a new session every # calls. (see the Workaround for the SYS0008 error). Note that this is only a workaround -- not a solution! (see also SYS0008 - 2 - )
Example for the SYS0008 error
/* example program to generate a �SYS0008 error */ /* This program generates a �SYS0008 error after about 90 rounds if */ /* the file TATA.TXT does not exist */ /* see also the Workaround */ "C:" "CD \" "MD C:\TOTO" "MD C:\TOTO\TOTO" "MD C:\TOTO\TOTO\TOTO" "CD C:\TOTO\TOTO\TOTO" CHEMIN = "TATA\TATA\TATA.TXT" do i = 1 to 100 /* this DIR command causes the �SYS0008 error */ /* after about 40 to 80 rounds */ "DIR "CHEMIN if RC = 0 then say "OK" else say i end /* do i = 1 to 100 */ exit
Workaround for the SYS0008 error
/* workaround for the SYS0008 error */ /* get the current round count and session no. */ parse arg round sessionNo if round = "" then round = 1 /* initial value is 1 */ if sessionNo = "" then sessionNo = 1 /* initial value is 1 */ /* get the name of this program */ parse source . . thisProg if sessionNo = 1 then do /* do initialisations only once */ "C:" "CD \" "MD C:\TOTO" "MD C:\TOTO\TOTO" "MD C:\TOTO\TOTO\TOTO" "CD C:\TOTO\TOTO\TOTO" end /* if sessionNo = 1 then */ CHEMIN = "TATA\TATA\TATA.TXT" /* this is an endless loop! */ do i = round if i // 40 = 0 then do /* start a new session every 40 rounds */ /* You may use additional parameters or a private */ /* queue to pass global variables to the next */ /* pass */ "start /c /f " thisProg i+1 sessionNo+1 /* close this session */ "exit" end /* if i // 40 = 0 then */ /* execute the needed OS/2 commands */ "DIR "CHEMIN ">NUL" /* process the results here */ say "session: " || sessionNo || ", round " || i || " --> RC = "rc end /* do i = round */ exit
SYS0008 - 2 -
Problem: Passing a null string as a command (which is not a valid command) to the CMD interpreter will return the �SYS0008 error message after the 32nd iteration.
Example:
/* example for the �SYS0008 bug */ do i=1 to 33 /* the next stmt returns a */ /* null string to the CMD */ /* which leads to the */ /* �SYS0008 error after the */ /* 32nd execution. */ Beep(220,250) say "i is " || i || ", rc is " || RC end /* do i=1 to 33 */
Note that you can replace the statement Beep(220,250) with every other statement returning a null string -- even with a function defined in your REXX program!
This seems to be an OS/2 interpreter bug. Note that 4OS2 does handle this situation correctly.
Hint: Do not use a function returning a null string this way (see also SYS0008).
This bug seems to be fixed in WARP 4 Fixpack #5.
REXX programs without an extension
Problem: The REXX interpreter executes an external procedure from a file with any or without an extension and/or without the leading comment normally necessary for REXX programs.
Hint: There's a bug in the OS/2 WARP REXX interpreter which allows the use of files with any extension or without an extension for external REXX procedures. These files also don't need the leading comment.
Note that if there's a directory with the name of the external REXX procedure prior to the REXX procedure in your �PATH, REXX tries to "execute" the directory and fails with the error REX0003 - Program is unreadable.
This bug was fixed in the WARP 3 FixPack #8 (Source: APAR PJ19105) - and is again there after WARP 3 FixPack #17. It's still there in WARP 4. And again fixed in Fixpack #6 for WARP 4.