Page 1 of 1

Invalid whole number when returning a string

PostPosted: Thu Dec 18, 2014 5:41 pm
by deucalion0
I wrote a subroutine in Rexx, the code works, it does what it is meant to, but at the end I get this message:

IRX0026I Error running R12, line 129: Invalid whole number

My code:


n="Paul"
n = mobile(n)
say n

mobile:                                               
   PARSE ARG name                                     
select                                                 
when name="Paul"THEN DO               
name="Paul Smith"   
END                                                   
when name=="Robert"THEN DO               
name="Robert Smith"   
end                                                   
otherwise nop
end         
             
RETURN name 
EXIT         


I worry when I get messages, I cannot have this Rexx fail on me. I spent a long time Googling this message but I did not get any clarification, any advice is much appreciated!

Thank you!

Re: Invalid whole number when returning a string

PostPosted: Thu Dec 18, 2014 7:00 pm
by Pedro
Your program calls the MOBILE() function, which returns a full name, then returns to the caller. Then the main routine falls through to the MOBILE procedure.

I think you need to end the main routine with a RETURN or an EXIT before it falls through to the MOBILE procedure.

Re: Invalid whole number when returning a string

PostPosted: Thu Dec 18, 2014 7:23 pm
by deucalion0
What a silly mistake I made!

I had my exit in the wrong place! I forgot to move it before the subroutune, many thanks for point out what was staring me right in the face! :)

Cheers!!