cancel
Showing results for 
Search instead for 
Did you mean: 
NetizenSmith
New member
2 1 0 0
Message 1 of 3
770
Flag Post

Solved!

Program gives Syntax Error when run in RPN Mode

HP Recommended
HP Prime

Hi,

 

Does anyone knwo why this works in Textbook mode but not RPN?

 

EXPORT BITSET(Word, BitNum)

BEGIN

LOCAL Tmp;

Tmp:= BITSL(SETBITS(#1,GETBITS(Word)), BitNum);

RETURN BITOR(Word, Tmp);

END;

 

I'm calling the program like this:

 

BITSET(#FEh,#0h)

 

In Textbook mode it gives #FFh as you'd expect but in RPN it give Syntax Error

 

Thanks.

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Joe_Horn
Level 8
650 635 124 222
Message 2 of 3
Flag Post
HP Recommended

The reason you're getting a Syntax Error is because you are using algebraic notation when you have your Prime set to expect Reverse Polish Notation.  Algebraic entry mode expects the arguments of a function to follow the function name in parentheses, separated by commas, like this:

 

FOOBAR(5,6,7)

 

But RPN entry mode always expects the arguments to already be on the stack when the function is called, like this:

 

5 Enter 6 Enter 7 Enter FOOBAR

 

Prime uses a special RPN syntax which tells functions how many arguments to take from the stack, so in the above example, you might have to say FOOBAR(3) in RPN mode, which tells FOOBAR to take 3 arguments from the stack.

 

Therefore, in your example, I strongly suspect that you should put #FEh and #0h on the stack first, then execute either BITSET or BITSET(2).  Please try that and let us know if it works.

 

Disclaimer: I don't work for HP. I'm just another happy HP calculator user.

-Joe-

View solution in original post

Tags (1)
Was this reply helpful? Yes No
2 REPLIES 2
Joe_Horn
Level 8
650 635 124 222
Message 2 of 3
Flag Post
HP Recommended

The reason you're getting a Syntax Error is because you are using algebraic notation when you have your Prime set to expect Reverse Polish Notation.  Algebraic entry mode expects the arguments of a function to follow the function name in parentheses, separated by commas, like this:

 

FOOBAR(5,6,7)

 

But RPN entry mode always expects the arguments to already be on the stack when the function is called, like this:

 

5 Enter 6 Enter 7 Enter FOOBAR

 

Prime uses a special RPN syntax which tells functions how many arguments to take from the stack, so in the above example, you might have to say FOOBAR(3) in RPN mode, which tells FOOBAR to take 3 arguments from the stack.

 

Therefore, in your example, I strongly suspect that you should put #FEh and #0h on the stack first, then execute either BITSET or BITSET(2).  Please try that and let us know if it works.

 

Disclaimer: I don't work for HP. I'm just another happy HP calculator user.

-Joe-

View solution in original post

Tags (1)
Was this reply helpful? Yes No
NetizenSmith
Author
New member
2 1 0 0
Message 3 of 3
Flag Post
HP Recommended

That did the trick. Thanks joe. Seems obvious (in hindsight!)

Was this reply helpful? Yes No
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation