hp prime - sending program results to the stack



#2

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


#3

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


#4

You can always return a list or matrix.


#5

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.

#6

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.

#7

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.


#8

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending little images to the Prime (...and Program name bug?) Erwin Ried 19 7,487 12-10-2013, 05:35 PM
Last Post: Erwin Ried
  Problem with debug HP prime program, somebody help me? Carlos CM (Mexico) 6 3,381 12-05-2013, 03:07 PM
Last Post: Carlos CM (Mexico)
  HP PRIME: APP program code DISAPPEARS !! Joseph Ec 0 1,224 11-25-2013, 11:35 AM
Last Post: Joseph Ec
  HP 50g - select characters on the stack, copy/paste Sean Freeman 7 2,754 11-20-2013, 07:11 AM
Last Post: Sean Freeman
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 2,285 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  Prime: Program size limited to 64K? Erwin Ried 4 2,059 11-17-2013, 11:42 PM
Last Post: Joseph Ec
  [HP-Prime] Picking elements from a List in a program Jean-Michel 3 2,032 11-15-2013, 04:16 AM
Last Post: dg1969
  HP Prime: Recommendation for future RPN Program Mode BruceTTT 3 2,185 11-13-2013, 10:03 PM
Last Post: BruceTTT
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 2,738 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 1,995 11-11-2013, 02:19 PM
Last Post: Thomas Radtke

Forum Jump: