Post Reply 
Single User Defined Program Key Press to Answer.
07-06-2021, 09:39 PM (This post was last modified: 07-06-2021 09:40 PM by matalog.)
Post: #1
Single User Defined Program Key Press to Answer.
This little program, will take the last entry in the stack (in Algebraic mode anyway) and use it to display the subtotal, and amount of tax.

Code:
KEY K_Ln()
BEGIN
LOCAL G:=ROUND(Ans(1)/1.2,2);
LOCAL H:=ROUND(Ans(1)/6,2);
LOCAL I:={};
I(1):=G;
I(2):=H;
MSGBOX(I);
RETURN 46;
END;

It assumes the last number on the stack is the total including tax, and that you want, what the total would have been before tax, and the amount of tax. Pressing LN activates it.

Rather than teaching people how to calculate tax, it is an example of a program that works by a single keypress and displays a result.

Return 46; at the end of the program ensures that the program doesn't return anything to the stack, or the live calculator line. It basically presses the On button, which I assume to be harmless.

Any suggestions of a way to get the result to the stack would be very welcome!
Find all posts by this user
Quote this message in a reply
07-09-2021, 07:27 PM
Post: #2
RE: Single User Defined Program Key Press to Answer.
Hello, how did you learn RETURN 46; is like pressing the on button?
Might you know the value for the ENTER key?
Find all posts by this user
Quote this message in a reply
07-09-2021, 09:52 PM
Post: #3
RE: Single User Defined Program Key Press to Answer.
(07-09-2021 07:27 PM)kevinwaite Wrote:  Hello, how did you learn RETURN 46; is like pressing the on button?
Might you know the value for the ENTER key?

I have attached the image from page 652 of the manual, which describes what the rules are for GETKEY. I discovered that the result of a program (or key instruction) written this way, will be that the 'number' returned, will show itself as the key that the 'number' represents.

The ENTER key will be 30 and shift and ENTER should be 51+30, with alpha+ENTER being 51+51+30, and shift+alpha+ENTER being 51+51+51+30.

I assume that there could be some use for this, but I cannot think of a good one off hand. The use of a Key instruction program like this, seems to be bound to only outputting a single instruction to be used to simulate the press of a key.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
07-09-2021, 10:43 PM
Post: #4
RE: Single User Defined Program Key Press to Answer.
(07-06-2021 09:39 PM)matalog Wrote:  Return 46; at the end of the program ensures that the program doesn't return anything to the stack, or the live calculator line. It basically presses the On button, which I assume to be harmless.

Not quite harmless. On button clear line entry.

Return ""; may be more "harmless".
Find all posts by this user
Quote this message in a reply
07-11-2021, 04:29 AM
Post: #5
RE: Single User Defined Program Key Press to Answer.
RETURN 46;

On my hp prime puts 46 on the level 1: stack location.

Hmm?
Find all posts by this user
Quote this message in a reply
07-11-2021, 09:45 AM
Post: #6
RE: Single User Defined Program Key Press to Answer.
(07-11-2021 04:29 AM)kevinwaite Wrote:  RETURN 46;

On my hp prime puts 46 on the level 1: stack location.

Hmm?

It sounds like you didn't use the program at the start of this post. The behaviour you describe is what people here actually want, but it isn't attainable from a single key press. What you are describing is usually achieved by adding RETURN 46; just before END; in a normal program that begins with EXPORT NAME(), and not KEY N_AME().
Find all posts by this user
Quote this message in a reply
Post Reply 




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