HP Forums

Full Version: Message Box Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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
Thanks Cyrille. That took care of the problem.

Tim
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
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.
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
Reference URL's