Post Reply 
PPL Info-Box
09-30-2023, 07:37 PM
Post: #1
PPL Info-Box
Hi forum,
rather new to PPL programming, coming from HP48G++...
Hope it's not a FAQ, but searching the forum did not retrieve any results.

- How do I avoid the info box popping up at the termination of a PPL program ?
- What is the porpose of this info box ?
- What parameter is returned with the box ?

Thanks for info
Andreas
Find all posts by this user
Quote this message in a reply
10-01-2023, 04:53 AM
Post: #2
RE: PPL Info-Box
(09-30-2023 07:37 PM)DG7RBN Wrote:  - How do I avoid the info box popping up at the termination of a PPL program ?
- What is the porpose of this info box ?
- What parameter is returned with the box ?

Share your program here in its simplest form (without any unnecessary additions), when the info box appears. It will be easier to explain with an example.

Piotr
Find all posts by this user
Quote this message in a reply
10-02-2023, 01:19 PM
Post: #3
RE: PPL Info-Box
Hello Piotr and group,
here is a very simple PPL example for this strage behaviour:
Code:

EXPORT Test()
BEGIN
 MSGBOX("Hello world !");
END;
After closing the MSGBOX with OK, another box with an (i) marker pops up with the program name and a number "1", that must again be closed with OK. What for ?
Did nobody else get bugged by this ? ;-)
Andreas
Find all posts by this user
Quote this message in a reply
10-02-2023, 02:00 PM (This post was last modified: 10-02-2023 02:01 PM by matalog.)
Post: #4
RE: PPL Info-Box
In this case you can exclude the MSGBOX part and just have the string on its own line and that will be returned - Beside the name of the program.

Code:

EXPORT Test()
BEGIN
 "Hello world !";
END;
Find all posts by this user
Quote this message in a reply
10-02-2023, 02:04 PM (This post was last modified: 10-02-2023 02:07 PM by matalog.)
Post: #5
RE: PPL Info-Box
Another option would be to run the programs the way that they may have been expected to be run, by typing their name into the calculator. That does not bring up the final message box that bothers you.

To run your program, you would just type "Test()" into the home screen without the quotes and the program will run as you expected.
Find all posts by this user
Quote this message in a reply
10-02-2023, 02:24 PM
Post: #6
RE: PPL Info-Box
(10-02-2023 01:19 PM)DG7RBN Wrote:  Hello Piotr and group,
here is a very simple PPL example for this strage behaviour:
Code:

EXPORT Test()
BEGIN
 MSGBOX("Hello world !");
END;
After closing the MSGBOX with OK, another box with an (i) marker pops up with the program name and a number "1", that must again be closed with OK. What for ?
Did nobody else get bugged by this ? ;-)
Andreas

Hi Andreas,

In PPL, almost everything is a function, including MSGBOX. The result of a function is always the result of the last executed instruction or assignment. For example, if you write a function like
Code:
EXPORT Test()
BEGIN
  1+2;
END;
the result will be 3, and you don't need to use RETURN here if it's the last operation in the function. However, you have to use RETURN if you want to exit the function conditionally and return a specific result, for example
Code:
EXPORT Test(val)
BEGIN
  IF val<10 THEN
    RETURN "less than 10";
  ENDIF;
  "more or equal 10";
END;

When you run a program from the HOME (stack) level, you will only see MSGBOX, and then the result will appear as an entry on the stack, so the second popup window won't appear again. However, from what you're describing, it seems you ran your program from the 'Program Catalog,' which always displays the result of the last executed function (program). Therefore, you received "1" as the result from MSGBOX (which always returns "1" as a function). To work around this, you can use FREEZE right after MSGBOX:
Code:
EXPORT Test()
BEGIN
  MSGBOX("Hello world !");
  FREEZE;
END;

This will prevent the second popup from appearing even when the program is run from the 'Program Catalog', but this solution has one small drawback. I wonder if you'll notice it... Wink

Best regards,
Piotr
Find all posts by this user
Quote this message in a reply
10-08-2023, 12:40 PM
Post: #7
PPL Info-Box --- kind of weird
Thank you for the information, but I still do not get the point:

- What's the use of this info box ? I get a return paramater displayed, even if I do not request one.
- Is it a left over debug stub, that was never cleaned up ?
- Why does a PPL program behave differently, if I call it from the "Home" or from the "Program" environment ?

Yes, I know there are some "tricks" to avoid this strange behaviour, but I had hoped one of the developers of the Prime software would explain the design idea behind this "weirdo" behavior ;-)

Regards
Andreas
Find all posts by this user
Quote this message in a reply
10-09-2023, 04:55 AM
Post: #8
RE: PPL Info-Box
Hi Andreas,

I am not an HP developer, but I understand this behavior, and it seems very sensible for a calculator. The premise of working on the HP Prime calculator is that we perform calculations in HOME, where we have a history of the operations we've executed (we can review it, revert to earlier results, etc.). The result of every mathematical operation, every built-in function, or our own function (program) is first placed in the 'Ans' variable, which is then stored as a result in the HOME history stack. We can refer to this variable by Ans in subsequent calculations.
Let's assume we have a simple function that takes a parameter and returns its doubled value:
Code:
EXPORT X2(x)
BEGIN
  x+x;
END;

To execute this function during normal operation, we go to HOME (the standard place for executing functions/calculations) and enter the command X2(value), e.g.:
Code:
X2(3)
and in this way, we get the result in the Ans variable as well as on the stack: 6.

If we now want to add 2 to Ans, we simply issue the command
Code:
Ans+2
and get the result of 8 (and Ans will also be set to 8 at this point).
If at any moment we don't want to disturb the history of our work or don't want to affect the Ans variable value, we can enter the 'Program Catalog' and execute our function outside the history stack "in test mode", which will ask us for the necessary parameters (if they exist in the program) and will execute the operations contained in it in the same way as it does in HOME, only it won't change the Ans variable, instead, this test result will be shown on the screen. If you want to write a "program" that doesn't return any values (and not a "function", which by definition always has a value) you should create a new application and add it to the "Application Library", accessible via the "Apps" key. Each application has its own icon and is started by tapping on it.

So, answering your questions:
(10-08-2023 12:40 PM)DG7RBN Wrote:  - What's the use of this info box ? I get a return paramater displayed, even if I do not request one.

If you write a function, you expect a result, and if you don't expect a result, don't create a function but create an application instead.

(10-08-2023 12:40 PM)DG7RBN Wrote:  - Is it a left over debug stub, that was never cleaned up ?

It can be said that this is a way of testing the function and verifying the result, so one must expect that the Ans result will be displayed on the screen as the final outcome.

(10-08-2023 12:40 PM)DG7RBN Wrote:  - Why does a PPL program behave differently, if I call it from the "Home" or from the "Program" environment ?

Internally, the function behaves exactly the same in both cases, but when run from the 'Program Catalog', it doesn't overwrite the Ans variable value and thus has to present the result differently, so it does this by displaying a dialog box. To me, these mechanisms are understandable and very ergonomic.

I hope this has clarified your doubts.

Piotr
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)