HP Forums
Getting usable numbers from a Program Preferrably on 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 usable numbers from a Program Preferrably on Stack (/thread-16940.html)



Getting usable numbers from a Program Preferrably on Stack - matalog - 05-15-2021 09:39 AM

I have written a little program to help my day to day business, that will convert feet and inches into metres. The program will currently return the metres value to the stack, and that is a good start.

I wonder if there would be a way to have the feet and inches values also sent to the stack for future viewing, not just to the terminal window.

While i'm asking about sending numbers to stack from a program, is there any way to put more than one single number to stack, so that I can scroll up and see it, or press enter on it, to use it in a future calculation.

Thanks for any help.


RE: Getting usable numbers from a Program Preferrably on Stack - Eddie W. Shore - 05-15-2021 03:59 PM

The RETURN command can return a list or vector of values to the stack, not just one value.


RE: Getting usable numbers from a Program Preferrably on Stack - matalog - 05-15-2021 04:02 PM

(05-15-2021 03:59 PM)Eddie W. Shore Wrote:  The RETURN command can return a list or vector of values to the stack, not just one value.

That's great, I assume that the individual values of the lists will be usable as separate numbers on the stack, so I could go to one of them and press enter, and that single number would be brought to the current calculation line?

Thanks for the reply.


RE: Getting usable numbers from a Program Preferrably on Stack - Stevetuc - 05-16-2021 06:33 AM

(05-15-2021 04:02 PM)matalog Wrote:  
(05-15-2021 03:59 PM)Eddie W. Shore Wrote:  The RETURN command can return a list or vector of values to the stack, not just one value.

That's great, I assume that the individual values of the lists will be usable as separate numbers on the stack, so I could go to one of them and press enter, and that single number would be brought to the current calculation line?

Thanks for the reply.

And see this thread. https://www.hpmuseum.org/forum/thread-16946.html

A user defined key can return a string containing multiple values space separated to the command line. Pressing Enter will place those values as separate numbers on the stack.

In the code below, userkey Shift User 2 will place 4 3 2 1 on the RPN command line. Pressing Enter will place the following into Stack levels 1-4

4 (stack 4)
3
2
1 (stack 1)

Code:

KEY K_2()
BEGIN
RETURN "4 3 2 1";
END;