Post Reply 
Prime Programming help needed for a (still) newb Prime user
06-17-2021, 07:00 PM (This post was last modified: 06-17-2021 07:04 PM by spiff72.)
Post: #1
Prime Programming help needed for a (still) newb Prime user
Hello all,

I have a programming question that is trivial on my HP50g, but not so much with the Prime.

I often use my calculator as a simple "counter" for incrementing a number on the stack by a varying number, and I assign simple programs for these to softkeys.

The simplest possible example (as I do it on the 50g) - "count by 1":
<< 1 + >>

I store this as "CNT1", and press the softkey for it (after initially putting a zero on the stack), and I can increment the value on the stack with one button press.

For the Prime, I came up with a simple prog:
Code:
// change the value in the RETURN statement for
// different count increments
EXPORT countby(c1)
BEGIN
 RETURN c1+1;
END;

KEY K_Comma()
BEGIN
 RETURN "countby()";
END;

The above works, and assigns the countby() program to the unshifted comma key for the user keyboard.

In practice this is rather clunky, though:
- Put zero on stack
- Press shift
- Press Help (for user keyboard)
- Press comma key (which puts countby() in the command line)
- Press enter

Is there a more elegant way to do this without requiring 4 keypresses? (Maybe within a custom app with an option to change the count increment?)

Just fishing for ideas - I am sooo used to the RPL programming that this Prime is hard to get used to!
Find all posts by this user
Quote this message in a reply
06-17-2021, 07:52 PM
Post: #2
RE: Prime Programming help needed for a (still) newb Prime user
The user guide has a brief explanation on the GETKEY function.
Apparently the code for the comma is 29.

I have not coded an example yet.

Thanks.
Find all posts by this user
Quote this message in a reply
06-17-2021, 08:52 PM (This post was last modified: 06-17-2021 08:55 PM by C.Ret.)
Post: #3
RE: Prime Programming help needed for a (still) newb Prime user
Hello,

To use my HP prime as a simple counter, I never made something so elaborate.

In HOME or CAS view, I press [ 0 ] [ ENTER ] to enter zero in the results stack.
Then I press [ Shift ][ Ans ] [ + ] [ 1 ] [ENTER] to initiate increment by one.
Then any further press on [ ENTER ] increase the “counter” one more unit.

If you whish, you can program the "Ans+1"; sequence on a specific User key to spare a few keystrokes.
Find all posts by this user
Quote this message in a reply
06-17-2021, 11:39 PM (This post was last modified: 06-17-2021 11:42 PM by spiff72.)
Post: #4
RE: Prime Programming help needed for a (still) newb Prime user
(06-17-2021 08:52 PM)C.Ret Wrote:  Hello,

To use my HP prime as a simple counter, I never made something so elaborate.

In HOME or CAS view, I press [ 0 ] [ ENTER ] to enter zero in the results stack.
Then I press [ Shift ][ Ans ] [ + ] [ 1 ] [ENTER] to initiate increment by one.
Then any further press on [ ENTER ] increase the “counter” one more unit.

If you whish, you can program the "Ans+1"; sequence on a specific User key to spare a few keystrokes.

EDIT:
Just tried it out - that works for me! It doesn't work in the "home" screen when in RPN mode (my usual mode), but in CAS mode it works nicely.

Thanks again!

Hmmm - I will try that out. Thanks!
Find all posts by this user
Quote this message in a reply
06-18-2021, 04:50 PM
Post: #5
RE: Prime Programming help needed for a (still) newb Prime user
That's a fact, I never use my HP Prime in RPN mode, I have much better hardware for this.
Find all posts by this user
Quote this message in a reply
Post Reply 




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