Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Bad arithmetic conversion when assigning a stem var

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

Active User


Joined: 25 Apr 2007
Posts: 206
Location: Bangalore

PostPosted: Tue Nov 26, 2019 11:29 am    Post subject: Bad arithmetic conversion when assigning a stem var
Reply with quote

I am reading file into stem var inrec.

"execio * diskr indd (stem inrec. finis"

last-var = inrec.1

The above assignment statement is failing with bad arithmetic conversion error.

I am able to see value 191003 correctly when I display inrec.1 using say.

Pls advise
Back to top
View user's profile Send private message

prino

Senior Member


Joined: 07 Feb 2009
Posts: 1168
Location: Vilnius, Lithuania

PostPosted: Tue Nov 26, 2019 2:05 pm    Post subject:
Reply with quote

Show a trace, straight assignments in REXX cannot cause this error!
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 327
Location: Denmark

PostPosted: Tue Nov 26, 2019 3:47 pm    Post subject:
Reply with quote

'last-var = inrec.1 ' means subtract value of var=inrec.1 (which would evaluate to 0 or 1) from value of last.
Change the minus sign to something else.
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 327
Location: Denmark

PostPosted: Tue Nov 26, 2019 5:42 pm    Post subject:
Reply with quote

Sorry, my explanation was wrong - but it is caused by the minus sign in the varname.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 632
Location: Maryland

PostPosted: Tue Nov 26, 2019 7:12 pm    Post subject:
Reply with quote

Willy Jensen wrote:
'last-var = inrec.1 ' means subtract value of var=inrec.1 (which would evaluate to 0 or 1) from value of last.

Even worse:

The expression last-var = inrec.1
is in fact considered as
last - (var = inrec.1)
where the comparison (var = inrec.1) is always valid; it produces either 1, or 0 (with the highest probability of 0)

Next, the current value of last is considered:

1) when last is not defined, the value is 'LAST'
An attempt to calculate 'LAST' - 1 or 'LAST' - 0 would cause "bad arithmetic conversion"

2) when last is defined as non-numeric, like last = 'Hello!', then the same result as #1: "bad arithmetic conversion"

3) when last is defined as numeric, like last = 12345, then result of subtraction would be either 12345, or 12344, and then this numeric value would tried to be considered as invalid REXX expression, or TSO command, and would cause another error.
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 Can you manually set an EOF marker in... Don Allard CLIST & REXX 5 Sat Nov 02, 2019 12:30 am
No new posts String to ASCII conversion JPLMARTINS COBOL Programming 4 Sun Sep 29, 2019 12:00 am
No new posts REXX EXECIO STEM No newline Harold Barnes CLIST & REXX 3 Tue Sep 17, 2019 6:07 am
No new posts Pack to Unpack conversion for sending... A_programmers COBOL Programming 13 Wed Sep 11, 2019 10:46 pm
No new posts Alphanumeric to Packed Decimal Conver... Vijay_Sirisha COBOL Programming 2 Mon May 27, 2019 2:52 am

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