View previous topic :: View next topic |
Author |
Message |
Nancy Beginner
Joined: 23 May 2003 Posts: 77 Topics: 26
|
Posted: Thu Aug 07, 2003 2:33 am Post subject: Error in a simple REXX exec !!! |
|
|
Hi,
I am a beginner. This is simple program in REXX to add two numbers.
/* rexx ******************************/
say 'enter a no '
pull number1
say 'enter second no '
pull number2
sum = number1 + number2
say 'the sum is ' sum
Its giving error in statement sum = number1 + number2 .
Please suggest the reason.
Thanks in advance.
Last edited by Nancy on Thu Aug 07, 2003 4:11 am; edited 1 time in total |
|
Back to top |
|
 |
Premkumar Moderator

Joined: 28 Nov 2002 Posts: 77 Topics: 7 Location: Chennai, India
|
Posted: Thu Aug 07, 2003 2:40 am Post subject: |
|
|
Nancy,
Would you mind me asking, what error it gives you? |
|
Back to top |
|
 |
Nancy Beginner
Joined: 23 May 2003 Posts: 77 Topics: 26
|
Posted: Thu Aug 07, 2003 2:43 am Post subject: |
|
|
Error is -->
Error running R0807A, line 6: Bad arithmetic conversion
Regards |
|
Back to top |
|
 |
Premkumar Moderator

Joined: 28 Nov 2002 Posts: 77 Topics: 7 Location: Chennai, India
|
Posted: Thu Aug 07, 2003 2:48 am Post subject: |
|
|
Probably you are not entering numbers when it asks you to 'enter a no ' and 'enter second no '. What are you typing? |
|
Back to top |
|
 |
Nancy Beginner
Joined: 23 May 2003 Posts: 77 Topics: 26
|
Posted: Thu Aug 07, 2003 2:50 am Post subject: |
|
|
I am simply entering the numbers only. U can also try it on your machine. It wont take more than 5 minutes. |
|
Back to top |
|
 |
Dibakar Advanced

Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Thu Aug 07, 2003 3:02 am Post subject: |
|
|
Try "say number1 number2' before sum to see if it is coming properly? |
|
Back to top |
|
 |
Premkumar Moderator

Joined: 28 Nov 2002 Posts: 77 Topics: 7 Location: Chennai, India
|
Posted: Thu Aug 07, 2003 3:38 am Post subject: |
|
|
Nancy,
Yes. What I did before my first post is to try in our machine. It is working fine for me. |
|
Back to top |
|
 |
Nancy Beginner
Joined: 23 May 2003 Posts: 77 Topics: 26
|
Posted: Thu Aug 07, 2003 3:51 am Post subject: |
|
|
yes. The error is because of spaces only. i am now trying to use PARSE but the same error is coming in that also.
My code is looking like -
/* rexx ******************************/
say 'enter a no '
pull number1
PARSE VAR NUMBER1 VALUE1 SPACE1
say 'enter second no '
pull number2
PARSE VAR NUMBER2 VALUE2 SPACE2
say number1 number2
sum = value1 + value2
say 'the sum is ' sum
Regards |
|
Back to top |
|
 |
Nancy Beginner
Joined: 23 May 2003 Posts: 77 Topics: 26
|
Posted: Thu Aug 07, 2003 4:24 am Post subject: |
|
|
Working fine now. Actually the problem was with the way of execution. After entering the first number, when it asks for the second number, I was giving second no in that line only. hence it was taking the spaces. While it should be entered after hitting one ENTER again.
This can also be done by writing CLEAR in the second line of the program.
Thanks to all. |
|
Back to top |
|
 |
|
|