The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

hp prime - sending program results to the stack
Message #1 Posted by Giancarlo on 12 Oct 2013, 5:22 p.m.

Hello, Just received my prime TODAY and very very happy with it. Thanks to Tim and Cyrille and HP for the huge amount of work done sofar.

I wrote a small program and i would like to send the result of the calculation to the stack.

In the user guide i found three ways for showing the data:

1) Print which feeds the terminal that can be accessed through ON+T keys when the program ends

2) msgbox with a pop up box.

3) EXPORTing the result variable into the user variables that can be accessed accessing to the variable menu.

Is there a way to send the data directly to the stack?

Thanks

Giancarlo from Italy

      
Re: hp prime - sending program results to the stack
Message #2 Posted by Tim Wessman on 12 Oct 2013, 5:31 p.m.,
in response to message #1 by Giancarlo

Each function returns a single result on exit. If you are executing it in the home screen, it will return a result automatically (the last item in your program) or else you can use the return keyword.

If you mean to return multiple results separately, then no I don't know any way to do that at the moment.

TW

            
Re: hp prime - sending program results to the stack
Message #3 Posted by Marcus von Cube, Germany on 12 Oct 2013, 5:38 p.m.,
in response to message #2 by Tim Wessman

You can always return a list or matrix.

                  
Re: hp prime - sending program results to the stack
Message #4 Posted by Giancarlo on 12 Oct 2013, 6:15 p.m.,
in response to message #3 by Marcus von Cube, Germany

Hello and thank you for your prompt support. Here you are my program:

EXPORT RADIUS;
EXPORT GETRADIUS ()
BEGIN
INPUT(RADIUS);
MSGBOX(PI*RADIUS^2);
PRINT(PI*RADIUS^2);
RETURN PI*RADIUS^2;
END

Running that program in rpn/home/functions the output of the program doesn't go into the stack pile. I would like to have the result of the program directly into the stack for further calculations.

Am I doing something wrong?

Thanks

Giancarlo

Ps edited for bad formatting

Edited: 12 Oct 2013, 6:20 p.m.

                  
Re: hp prime - sending program results to the stack
Message #5 Posted by Eddie W. Shore on 13 Oct 2013, 9:44 a.m.,
in response to message #3 by Marcus von Cube, Germany

Returning a list or matrix is also how I would approach returning multiple outputs on to the stack/entry screen.

For tagged results, I use MSGBOX (PRINT could work as well) prior to ending the program. That way you get a summary and still return results to the stack. For examples, say I have A and B as results, the end of a program could look like:

...
MSGBOX("Result A:"+A);
MSGBOX("Result B:"+B);
RETURN {A,B};
END;

or if I want to use PRINT:

...
PRINT(); // optional
...
PRINT("Result A:"+A); // add optional args. like color and font size if desired
PRINT("Result B:"+B);
RETURN {A,B}; // I don't think FREEZE or WAIT is required 
END;

Edited: 13 Oct 2013, 9:51 a.m.

      
Re: hp prime - sending program results to the stack
Message #6 Posted by Howard Owen on 13 Oct 2013, 2:22 p.m.,
in response to message #1 by Giancarlo

If you run a program from the HOME entry line, you will get the return value on the stack. If you run it from the program menu, you will only get the answer back in a message box. Any variable you have exported in your program will be available no matter which way you run the program.

            
Re: hp prime - sending program results to the stack
Message #7 Posted by Giancarlo on 15 Oct 2013, 2:00 a.m.,
in response to message #6 by Howard Owen

Hello guys, Thank you very much. Running the program from the stack leaves the result in the stack ready for further calculations.

This is esactly what i was looking for.

Thanks

Giancarlo from Italy


[ Return to Index | Top of Index ]

Go back to the main exhibit hall