Post Reply 
PPL Info-Box
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 


Messages In This Thread
PPL Info-Box - DG7RBN - 09-30-2023, 07:37 PM
RE: PPL Info-Box - komame - 10-01-2023, 04:53 AM
RE: PPL Info-Box - DG7RBN - 10-02-2023, 01:19 PM
RE: PPL Info-Box - matalog - 10-02-2023, 02:00 PM
RE: PPL Info-Box - matalog - 10-02-2023, 02:04 PM
RE: PPL Info-Box - komame - 10-02-2023, 02:24 PM
PPL Info-Box --- kind of weird - DG7RBN - 10-08-2023, 12:40 PM
RE: PPL Info-Box - komame - 10-09-2023 04:55 AM



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