Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Bad arithmetic conversion in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Gnanas N

Active Member


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

PostPosted: Fri Dec 14, 2007 9:39 pm    Post subject: Bad arithmetic conversion in REXX
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

Moderator Team Head


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

PostPosted: Fri Dec 14, 2007 9:43 pm    Post subject: Reply to: Bad arithmetic conversion in REXX
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: 788
Location: Chennai, India

PostPosted: Fri Dec 14, 2007 9:58 pm    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Sat Dec 15, 2007 10:03 pm    Post subject: Reply to: Bad arithmetic conversion in REXX
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: 788
Location: Chennai, India

PostPosted: Mon Dec 17, 2007 1:40 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 5 Wed Oct 04, 2017 6:54 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 47 Fri Sep 29, 2017 1:08 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us