Post Reply 
User defined touch-button menu (Softkeys)
06-30-2019, 03:27 PM (This post was last modified: 06-30-2019 03:44 PM by Stevetuc.)
Post: #21
RE: User defined touch-button menu (Softkeys)
(06-30-2019 09:06 AM)Arch Wrote:  @Gene222

Hi,

I tried your code once more.
[...]
Modified it a tiny bit. Just two questions:

1. The program returns only the last result to the stack when you exit it. I want to calculate several times and use each result for further calculations in RPN. Is there a way that all the previous results are returned to the stack for further use in RPN?
2. While the code works fine on the virtual calculator, I got problems on the real one. The following actions will result in a shutdown of the calculator ("Your calculator has a problem and will be rebooted in 3 seconds"):
a. hitting <enter> several times after a calculation
b. pressing exit after a calculation

Do you have any suggestions?

Thanks
Arch
I have a suggestion for 1. but it involves the use of a user key.
A user key allows to return a string unquoted to the command line. Pressing enter then executes the contents of the string.
By passing a string such as " s4 s3 s2 s1" ,the vars are each sent to a level of the stack.

In this demo program I read 4 levels of the stack , multiply them by 2 , and pass the results back to 4 stack levels, pushing the original data up.

To run , enter data into 4 stack levels, then <shift user 4> and <enter>

Code:

EXPORT s4,s3,s2,s1;
KEY K_4()
BEGIN
2▶Entry;
Ans(1)*2▶s1; 
Ans(2)*2▶s2; 
Ans(3)*2▶s3;
Ans(4)*2▶s4;
RETURN "s4 s3 s2 s1";
END;

You could customise the key definition in your program to return the vars you need, then execute the user key followed by enter to return your data to the stack
Find all posts by this user
Quote this message in a reply
06-30-2019, 09:07 PM
Post: #22
RE: User defined touch-button menu (Softkeys)
(06-30-2019 02:48 PM)Gene222 Wrote:  3. How you use and program the HP Prime is entirely up to you. But if I were writing that program, I would not use "User Tabs" or "program tabs", particularly if I just got the Prime. They are just too difficult to program.

To illustrate this point, if you take all the "user tab" code out of your program, you would be left with the program below. I move the LOCAL statement to the top of the page, only because that is the area where I normally put the LOCAL statement.

Code:
LOCAL a,b,z,i_Wert;

EXPORT i_SB2()
BEGIN
  INPUT({a,b,z});
  i_Wert:=(1/(2*π))*(ATAN((a*b)/(z*√(a^2+b^2+z^2)))+(a*b*z)/(√(a^2+b^2+z^2))*(1/(a^2+z^2)+1/(b^2+z^2)));
  RETURN i_Wert;
END;
Find all posts by this user
Quote this message in a reply
07-01-2019, 04:14 PM (This post was last modified: 07-01-2019 04:18 PM by Gene222.)
Post: #23
RE: User defined touch-button menu (Softkeys)
I think I misunderstood Arch's problem 2.

But first, in the shortened program, I move the LOCAL statement to the top of the program. This might adversely effect how you want the program to work. If you run the program and get an answer, and then you immediately run the program again, the last INPUT values are displayed in the INPUT screen. If you want the INPUT values to be cleared when you immediately run the program a second time, you have to place the LOCAL statement after the BEGIN statement as shown below.

Code:
EXPORT i_SB3()
BEGIN
  LOCAL a,b,z,i_Wert;
  INPUT({a,b,z});
  i_Wert:=(1/(2*π))*(ATAN((a*b)/(z*√(a^2+b^2+z^2)))+(a*b*z)/(√(a^2+b^2+z^2))*(1/(a^2+z^2)+1/(b^2+z^2)));
  RETURN i_Wert;
END;

Regarding Arch's problem 2, if you are in textbook mode and you run the program with inputs of 1, 2, and 3, you get the answer 1.65303414933 in the answer history, where the command line is blank. The Prime is set up where if you press the Enter key in textbook mode, the calculator will run the program again. If you want to use the answer for further manual processing, you can use the Ans key located in the lower right hand side of the calculator. If you wanted to use the answer in the equation (1 + 1.65303414933) / 2, you would type in (1 + Ans) / 2 then press Enter. You get the answer 1.32651707466.

The Ans key does not appear to work in RPN mode. I am not quite sure how you use the answer for further processing, but when you run the program with inputs of 1, 2, and 3, the answer of 1.65303414933 appears in the first stack register, where the command line is blank. Stack, Roll up, Roll down, and Pick softkeys are displayed. These softkeys seem to be used for manually manipulating the stack. If those softkeys don't work, you can double tap the 1.65303414933 to copy it to the command line. It is kind of strange that the stack softkeys only appear after you run the program. It sounds like Arch has figured out that after you run the program, you can also press Enter to duplicate the answer into the 2nd register. Unlike textbook mode, pressing the Enter key immediately after running the program does not run the program a second time.
Find all posts by this user
Quote this message in a reply
07-05-2019, 09:37 PM (This post was last modified: 07-07-2019 07:33 AM by Arch.)
Post: #24
RE: User defined touch-button menu (Softkeys)
I know that the calculation could be programmed a lot easier. In fact, the simplified code you posted is exactly the same I started with. There are some reasons why I still try to find another way e.g. by user defined menu:

1. Normally I calculate a series of results and I find it annoying that I have to restart the program over and over again. Especially since I have to do that by pressing at least four keys to call the program. Of course, one could argue that the code could be modified to allow for as many calculations as you want. But I couldn't find a way to return the results (all) to stack. Because I want to use them as an initial value for further calculations.
2. Just got the Prime, that's right. But I like to play around with the new functions. How else can I improve my abilities to program the thing. Wink

Arch


(06-30-2019 09:07 PM)Gene222 Wrote:  
(06-30-2019 02:48 PM)Gene222 Wrote:  3. How you use and program the HP Prime is entirely up to you. But if I were writing that program, I would not use "User Tabs" or "program tabs", particularly if I just got the Prime. They are just too difficult to program.

To illustrate this point, if you take all the "user tab" code out of your program, you would be left with the program below. I move the LOCAL statement to the top of the page, only because that is the area where I normally put the LOCAL statement.

Code:
LOCAL a,b,z,i_Wert;

EXPORT i_SB2()
BEGIN
  INPUT({a,b,z});
  i_Wert:=(1/(2*π))*(ATAN((a*b)/(z*√(a^2+b^2+z^2)))+(a*b*z)/(√(a^2+b^2+z^2))*(1/(a^2+z^2)+1/(b^2+z^2)));
  RETURN i_Wert;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)