View previous topic :: View next topic |
Author |
Message |
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Mon May 23, 2011 2:14 pm Post subject: Continue processing when REXX error is encountered |
|
|
I am running a REXX command in the foreground. I am accepting a number (supposedly in binary format) and then calling a subroutine which attempt to convert it to decimal.
I am purposely not sending it a valid binary number, because I want to return control to the calling program and have it display a message saying that the number sent was not a binary number if it encounters that condition.
Instead I am getting as follows: Code: |
129 +++ DATA_VALUE = C2D(DATA_VALUE,DATA_LENGTH)
41 +++ CALL 10000_CONVERT_FROM_BINARY
|
Error running @CONVERT, line 129: Incorrect call to routine
I tried using X=msg("OFF") to turn off messaging, but that didn't work. I didn't think that CONTROL ERRORS CANCEL would work, as I thought this is not the correct address space for that syntax.
Is there some standard way of allowing REXX to continue when it encounters an error like this? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12368 Topics: 75 Location: San Jose
|
Posted: Mon May 23, 2011 2:31 pm Post subject: |
|
|
jim haire,
Check the number using DATATYPE and see if it is 1 for valid binary number
Code: |
VALCHK = DATATYPE( DATA_VALUE, 'B' )
IF VALCHK = 1 THEN
DATA_VALUE = C2D(DATA_VALUE,DATA_LENGTH)
CALL 10000_CONVERT_FROM_BINARY
ELSE
DO
SAY 'INVALID BINARY VALUE'
RETURN TO-YOUR-MAIN-MODULE
END
|
Kolusu |
|
Back to top |
|
|
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Mon May 23, 2011 3:27 pm Post subject: |
|
|
Not quite what I'm looking for, but you've given me some ideas about how to check for this. I'll experiment with a few of these types.
When I said binary, I really meant COMP and COMP-4 type values. So the value +2222 is a hex 08AE.
I am going to want to do the same type of check for packed (COMP-3) numbers, that is, verifying when a user says a number is a PACKED number it really is packed.
In both of these cases, you cannot tell what type of number it is by visually looking at it. |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Mon May 23, 2011 4:33 pm Post subject: |
|
|
Possibly, i'm way off base here, but is not every value from x'0000' to x'FFFF' a valid binary (comp) value?
When considering valid packed-decimal data (comp-3), it is the usage that detrmines the datatype. The system does not care about the 1s and 0s that reside in memory or on some media. It is only when they are used as one type or another that problems occur. _________________ All the best,
di |
|
Back to top |
|
|
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Tue May 24, 2011 1:22 pm Post subject: |
|
|
You are correct. In the program I am writing, I am asking the user if they are working with binary, packed, or display (readable) numbers. It also checks for sign overpunched when looking at display types.
If I can do the conversion, I can determine if what I returned from the conversion was numeric. However, feeding bad values to the conversion routine causes the program to stop and display the line that caused the error.
It would be great if I had some way to allow the program to continue when an error like this is encountered and handle the error on my own. |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Tue May 24, 2011 2:05 pm Post subject: |
|
|
My users expect to enter a number (say a quantity or an amount). They do not expect to enter how this number is stored internally?
Quote: |
However, feeding bad values to the conversion routine causes the program to stop and display the line that caused the error. | Sounds like the conversion routine needs a bit of work to pass back an indicator rather than stop.
I do feel that i'm not on the same page. . . _________________ All the best,
di |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 699 Topics: 63 Location: USA
|
|
Back to top |
|
|
bob_buxton Beginner
Joined: 20 Dec 2002 Posts: 44 Topics: 0 Location: Hampshire, England
|
Posted: Tue May 24, 2011 3:42 pm Post subject: |
|
|
jim haire wrote: |
It would be great if I had some way to allow the program to continue when an error like this is encountered and handle the error on my own. |
Take a look at the REXX 'SIGNAL ON condition' statement if you want to define your own error handling routines _________________ Bob Buxton
Ex Websphere MQ for zOS development |
|
Back to top |
|
|
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Wed Jun 01, 2011 8:56 am Post subject: |
|
|
Sorry I didn't get back sooner. Had some higher priority work, but finally got to test out some of your responses,
I couldn't get the SIGNAL ON to work for this example. I tried SIGNAL ON ERROR NAME BINERROR and SIGNAL ON FAILURE NAME BINERROR and neither of them would pass me to the BINERROR label. I tried putting this statement before the offending statement and after the offending statement. I also tried at the very beginning of the program. None of them worked. I don't know if this is the type of error REXX expects to capture.
I did increase the number of NUMERIC DIGITS to 20 and it did help in some situations. It will still abend if I choose a binary number that is too large, but I don't see that happening.
This type of error sort of reminds me of the COBOL divide by zero error. If you hadn't edited properly and perform a statement that causes division by zero, your program abends and you have no way of stopping it from abending.
Thanks for all your responses. |
|
Back to top |
|
|
RonB Beginner
Joined: 02 Dec 2002 Posts: 93 Topics: 0 Location: Orlando, FL
|
Posted: Wed Jun 01, 2011 10:12 am Post subject: |
|
|
jim haire wrote: | This type of error sort of reminds me of the COBOL divide by zero error. If you hadn't edited properly and perform a statement that causes division by zero, your program abends and you have no way of stopping it from abending. |
Actually, you CAN prevent the abend, if you code the ON SIZE ERROR clause (and its associated imperative) as part of the DIVIDE statement.
Per the manual:
SIZE ERROR phrases
A size error condition can occur in four different ways:
. . .
When division by zero occurs.
. . . _________________ A computer once beat me at chess, but it was no match for me at kick boxing. |
|
Back to top |
|
|
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Wed Jun 01, 2011 12:45 pm Post subject: |
|
|
Thanks. I didn't know this and will use it the next time I could encounter this error. |
|
Back to top |
|
|
arnold57 Beginner
Joined: 01 Oct 2004 Posts: 30 Topics: 0
|
Posted: Wed Jun 01, 2011 6:51 pm Post subject: |
|
|
You are getting a syntax error, so you should use
Code: | SIGNAL ON SYNTAX NAME BINERROR |
You need to put the signal command where it gets executed before you encounter the error (normally at the very beginning). |
|
Back to top |
|
|
|
|