HP Forums
hp prime - sending program results to the stack - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: hp prime - sending program results to the stack (/thread-252767.html)



hp prime - sending program results to the stack - giancarlo - 10-12-2013

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 - Tim Wessman - 10-12-2013

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 - Marcus von Cube, Germany - 10-12-2013

You can always return a list or matrix.


Re: hp prime - sending program results to the stack - giancarlo - 10-12-2013

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 - Eddie W. Shore - 10-13-2013

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 - Howard Owen - 10-13-2013

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 - giancarlo - 10-15-2013

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