OS/2 Procedures Language 2/REXX


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Error Messages


There are two basic reasons errors occur when REXX is processing a 
procedure. 
One reason is because of the way the procedure is written; for example, 
unmatched quotation marks or commas in the wrong place.  Maybe an IF 
instruction was entered without a matching THEN. When such an error 
occurs, a REXX error message is issued. 
A second reason for an error to occur is because of an OS/2 command that 
the REXX procedure has issued.  For example, a COPY command can fail 
because the user's disk is full or a file cannot be found.  In this case, 
a regular OS/2 error message is issued.  When you write commands in your 
procedures, consider what might happen if the command fails to run 
correctly. 
When a command is issued from a REXX procedure, the command interpreter 
gets a return code and stores it in the REXX special variable, RC (return 
code).  When you write a procedure, you can test for these variables to 
see what happens when the command is issued. 
Here is how you discover a failure.  When commands finish running, they 
always provide a return code.  A return code of 0 nearly always means that 
all is well.  Any other number usually means that something is wrong. If 
the command worked normally (the return code was 0), you see the command 
prompt: 

[C:\]

and you return to the screen you ran your program from in Presentation 
Manager, or in the PMREXX application you see printed under the last line 
of the procedure, 

The REXX procedure has ended.

In the following example, ADD.CMD, there is an error in line 6; the plus 
sign (+) has been typed incorrectly as an ampersand (&). 

/* This procedure adds two numbers */
SAY "Enter the first number."
PULL num1
SAY "Enter the second number."
PULL num2
SAY "The sum of the two numbers is" num1 & num2
EXIT

When the above procedure, ADD.CMD, is run, the following error message is 
displayed. 

    6+++ SAY "The sum of the two numbers is" num1 & num2
REX0034: Error 34 running C:\REXX\ADD.CMD,line 6:logical value not 0 or 1

To get help on the error message, type: 

HELP REX0034

When help is requested, an error message such as the following is 
displayed: 

REX0034 ***Logical Value not 0 or 1***

Explanation: The expression in an IF, WHEN, DO WHILE, or DO UNTIL
             phrase must result in a '0' or a '1', as must any
             term operated on by a logical operator.

Any command that is valid at the command prompt is valid in a REXX 
procedure.  The command interpreter treats the command statement the same 
way as any other expression, substituting the values of variables, and so 
on.  (The rules are the same as for commands entered at the command 
prompt.) 
Return Codes: When the command interpreter has issued a command and the 
operating system has finished running it, the command interpreter gets the 
return code and stores it in the REXX special variable RC (return code). 
 In your procedure, you should test this variable to see what happens when 
the command is run. 
The following example shows a few lines from a procedure where the return 
code is tested: 

/* Testing the Return Code in a Procedure. */
'COPY a:*.lst b:'
IF rc = 0   /* RC contains the return code from the COPY command */
THEN
 SAY 'All *lst files copied'
ELSE
 SAY 'Error occurred copying files'
  

Inf-HTML End Run - Successful