IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Bad arithmetic conversion in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Dec 14, 2007 9:39 pm
Reply with quote

I tried a simple program. But I got the follwing error message after giving the two numbers as input.

7 +++ SM = NUMBER1 + NUMBER2
IRX0041I Error running ADDITION, line 7: Bad arithmetic conversion
***

Code is

Code:
/* REXX */                                               
/* THIS EXEC ADDS TWO NUMBERS AND DISPLAYS THEIR SUM. */ 
SAY 'PLEASE ENTER A NUMBER.'                             
PULL NUMBER1                                             
SAY 'NOW ENTER A NUMBER TO ADD TO THE FIRST NUMBER.'     
PULL NUMBER2                                             
SM = NUMBER1  + NUMBER2                                   
SAY 'THE SUM OF THE TWO NUMBERS IS' SM'.' 


Please clarify me.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Fri Dec 14, 2007 9:43 pm
Reply with quote

Please post the TRACE output from a real-time run. Thanks.

One of the two values entered is NOT numeric. You might want to add a check to validate their format first.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Dec 14, 2007 9:58 pm
Reply with quote

Kevin,

I have included TRACE in the code. And I come to know that NUMBER2 is not getting value from terminal, ie, NUMBER2 is null string. So, it causes bad arithmetic conversion.

Modified code is

Code:
 /* REXX */                                               
 /* THIS EXEC ADDS TWO NUMBERS AND DISPLAYS THEIR SUM. */ 
 SAY 'PLEASE ENTER A NUMBER.'                             
 PULL NUMBER1                                             
 SAY 'NOW ENTER A NUMBER TO ADD TO THE FIRST NUMBER.'     
 PULL NUMBER2                                             
 TRACE I                                                   
 SM = NUMBER1 + NUMBER2                                   
 SAY 'THE SUM OF THE TWO NUMBERS IS' SM'.'     


The input given is

PLEASE ENTER A NUMBER.
12
NOW ENTER A NUMBER TO ADD TO THE FIRST NUMBER.
*** 3


Why that *** is coming while giving NUMBER2(marked in blue color)?

The output is

8 *-* SM = NUMBER1 + NUMBER2
>V> "12"
>V> ""
8 +++ SM = NUMBER1 + NUMBER2
IRX0041I Error running ADDITION, line 8: Bad arithmetic conversion
***


How to resolve this?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Dec 14, 2007 10:17 pm
Reply with quote

*** is what you usually see when you screen is full and you need to hit enter before entering any data.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Sat Dec 15, 2007 10:03 pm
Reply with quote

gnanas,

Hit enter after *** and check. In my training, i was told to hit enter whenever *** comes up in the terminal.

Else try getting both the values in a single PULL statement like PULL VAR1 VAR2.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Mon Dec 17, 2007 1:40 pm
Reply with quote

Thanks Craq, Aaru.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top