HP Forums
Getting values from stack - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Getting values from stack (/thread-15807.html)



Getting values from stack - Francesco - 10-28-2020 07:06 PM

Hi to all
I'm new in HP PPL programming. I wrote a simple program that have as inputs two variables:
EXPORT myprog(value1,value2)
BEGIN
....
END

and it works fine. Running this program appears two edit box for variable insertion. How can I get these variables from stack ? That is I insert two values on stack and I want to give them as input to myprog.
regards


RE: Getting values from stack - pinkman - 10-28-2020 08:47 PM

You cannot pick values on the stack like in RPL/RPN, but here are the ways to use previous values:

Textbook or Algebraic entry mode:
myprog(Ans(1), Ans(2))

RPN entry mode:
(Assume the two vals are the last on stack)
myprog(2)

This is only applicable in Home view. If you use the program list to run your program, use the Menu/Get from Home (or CAS) function:
Select the program myprog
Touch the Run soft key
Highlight the first field then touch the Edit soft key
When editing, press the Menu key
Select Get from Home (or CAS) then Enter
Chose the value.



RE: Getting values from stack - Stevetuc - 10-28-2020 10:47 PM

(10-28-2020 07:06 PM)Francesco Wrote:  Hi to all
I'm new in HP PPL programming. I wrote a simple program that have as inputs two variables:
EXPORT myprog(value1,value2)
BEGIN
....
END

and it works fine. Running this program appears two edit box for variable insertion. How can I get these variables from stack ? That is I insert two values on stack and I want to give them as input to myprog.
regards

Not exactly what you asked for, but you can directly access RPN stack levels in your program without passing them as parameters. So something like this will work if called from home screen with 2 values on the stack:

EXPORT myprog()
BEGIN
Ans(1)*Ans(2) // eg. return stack1 x stack2
END;

It also works in textbook and algebraic entry modes and when run from program catalog


RE: Getting values from stack - Stefan_Titan2944A - 10-29-2020 05:57 PM

Hi Francesco,

you can!

Change HOME Settings > Entry to RPN

In HOME mode enter the input values in the order they are declared in your program.
e.g. EXPORT PROGRAM( INP1, INP2, ...)

INP1 ENTER
INP2 ENTER
...

Start the program via toolbox.
Leave the () blank.
Press ENTER.

Does not work when started from Program Catalog OR CAS mode!

Nevertheless, whatever Entry mode you'r in, starting from the toolbox will
provide PROGRAM() - () to be filled in accordingly - (INP1, INP2, ...) AND

starting from Program Catalog will always show the Entry Form.

Hope that helps.

regards
Stefan