Message Box Question
|
07-29-2020, 06:46 PM
Post: #1
|
|||
|
|||
Message Box Question
I've written a program for adding feet-inches-fractions that requires that the variable containing the accumulation be cleared at the start of a new calculation. I've written a key assignment to do this:
KEY KS_Bksp() BEGIN 0▶ΣdFT; MSGBOX("ΣdFT = 0"); END; The problem I'm having is that after the message box is displayed and any key is pressed, the screen changes from the RPN home screen to the Function Symbolic screen. Why does the screen change and how can I keep it from happening? |
|||
07-30-2020, 06:43 AM
Post: #2
|
|||
|
|||
RE: Message Box Question
Hello,
The return value of a key assignment program has a meaning! A number means: execute key number n A text means: insert text in command line. In your case, validating the msgbox returns a 1. which is key 1=Symb. add a return -1 to your code and it should work as you intend. Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
07-30-2020, 12:55 PM
Post: #3
|
|||
|
|||
RE: Message Box Question
Thanks Cyrille. That took care of the problem.
Tim |
|||
07-30-2020, 04:18 PM
Post: #4
|
|||
|
|||
RE: Message Box Question
Hi Cyrille,
I just read the MSGBOX section of the HP Prime User Guide (page 609) more closely and I see where MSGBOX returns true (1) for "OK" and false (0) for "Cancel". Since I did not use the optional settings (in square brackets) the default "OK" soft button is displayed for which the return value is 1. What I don't understand is why is the returned 1 is interpreted as an instruction to execute key 1. Is this behavior documented somewhere? I also don't understand the syntax of the optional [ ,ok_cancel?]: The program line MSGBOX("ΣdFT = 0" [ ,ok_cancel?]); gets a syntax error The program line MSGBOX("ΣdFT = 0" [ ,1]); gets a syntax error Is there supposed to be something between the opening square bracket and the comma? How is ok_cancel? set to trure or false? Thanks for all your help. Tim |
|||
07-30-2020, 10:35 PM
Post: #5
|
|||
|
|||
RE: Message Box Question
In HPPL there is no “void” return value. If you don’t specify a return value with the RETURN statement, then the return value of the last function called is used as a return value.
To avoid side effects with user key definition, you have to return -1. More details here: https://www.hpmuseum.org/forum/thread-14929.html The second argument of MSGBOX is True or False, 1 or 0, TRUE or FALSE, true or false. Don’t write the brackets, they are used in the documentation to show that the argument is optional. Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co |
|||
07-31-2020, 06:41 AM
Post: #6
|
|||
|
|||
RE: Message Box Question
Hello,
When wrting syntaxes, [] means optional. other symbols are also commonly used such as * (meaning the previous stuff can be repeated 0 to n times) or + (the previsou stuff can be repeated 1 to n times... for example, the function syntax in ppl would be: [export] name([param1[,paramn]+]) begin end; hope this helps. Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)