Post Reply 
HP50g R/S key
06-30-2019, 01:31 PM (This post was last modified: 06-30-2019 01:32 PM by Neve.)
Post: #1
HP50g R/S key
Hi,

I’m more used to using my HP41 than any other calculator, and I’ve always found that running programs which prompt you for input to be very uncomfortable on the HP50g. On the 41 you just input your data and hit the R/S key. On the 50g you need to perform an extra step (Left Shift—>Cont).
Is there a more convenient and more confortable way?

Thank You

Engineer & Senior IT Executive
Tall-Key HP41CL, CV, CX, 82162A Printer, 82143A Printer, 82160A HP-IL, 2 Card-Readers, Modules, Wand, HP50g.
Find all posts by this user
Quote this message in a reply
06-30-2019, 01:50 PM
Post: #2
RE: HP50g R/S key
The general idea with RPL is that you provide all the data that your program will need on the stack before running it, so no prompt is needed. Alternatively you can create and use menus in your program.

Either way round, no R/S key is needed.

CONT is used more for debugging. You stop a program's execution with HLT so you can look at the stack and whatever variable you need to examine and then resume execution with CONT.
Find all posts by this user
Quote this message in a reply
06-30-2019, 01:58 PM
Post: #3
RE: HP50g R/S key
(06-30-2019 01:50 PM)grsbanks Wrote:  The general idea with RPL is that you provide all the data that your program will need on the stack before running it, so no prompt is needed. Alternatively you can create and use menus in your program.

Either way round, no R/S key is needed.

CONT is used more for debugging. You stop a program's execution with HLT so you can look at the stack and whatever variable you need to examine and then resume execution with CONT.

I see... Less convenient and longer either way it would seem (to me)...

Engineer & Senior IT Executive
Tall-Key HP41CL, CV, CX, 82162A Printer, 82143A Printer, 82160A HP-IL, 2 Card-Readers, Modules, Wand, HP50g.
Find all posts by this user
Quote this message in a reply
06-30-2019, 02:01 PM
Post: #4
RE: HP50g R/S key
(06-30-2019 01:58 PM)Neve Wrote:  
(06-30-2019 01:50 PM)grsbanks Wrote:  The general idea with RPL is that you provide all the data that your program will need on the stack before running it, so no prompt is needed. Alternatively you can create and use menus in your program.

Either way round, no R/S key is needed.

CONT is used more for debugging. You stop a program's execution with HLT so you can look at the stack and whatever variable you need to examine and then resume execution with CONT.

I see... Less convenient and longer either way it would seem (to me)...

How do you store that data beforehand? Wouldn’t that be more of a hassle? Simpler to do it within the program like on the 41.
Or maybe I’m not used to doing it that way...

Engineer & Senior IT Executive
Tall-Key HP41CL, CV, CX, 82162A Printer, 82143A Printer, 82160A HP-IL, 2 Card-Readers, Modules, Wand, HP50g.
Find all posts by this user
Quote this message in a reply
06-30-2019, 02:15 PM
Post: #5
RE: HP50g R/S key
(06-30-2019 02:01 PM)Neve Wrote:  How do you store that data beforehand? Wouldn’t that be more of a hassle? Simpler to do it within the program like on the 41.
Or maybe I’m not used to doing it that way...

What do you mean by "store"?

You just type the data into the stack and let your program loose on it. For example, to calculate the volume of a sphere of height \(h\) and radius \(r\), \(v={\pi}r^2h\), you would enter \(h\) and then \(r\) onto the stack and run a program like this on them:

Code:
« → h r « r SQ π * h * →NUM » »
Find all posts by this user
Quote this message in a reply
06-30-2019, 02:33 PM (This post was last modified: 06-30-2019 02:34 PM by Neve.)
Post: #6
RE: HP50g R/S key
(06-30-2019 02:15 PM)grsbanks Wrote:  
(06-30-2019 02:01 PM)Neve Wrote:  How do you store that data beforehand? Wouldn’t that be more of a hassle? Simpler to do it within the program like on the 41.
Or maybe I’m not used to doing it that way...

What do you mean by "store"?

You just type the data into the stack and let your program loose on it. For example, to calculate the volume of a sphere of height \(h\) and radius \(r\), \(v={\pi}r^2h\), you would enter \(h\) and then \(r\) onto the stack and run a program like this on them:

Code:
« → h r « r SQ π * h * →NUM » »

I mean what if you need to reuse these same data again within the program. If they’re stored (STO) you can recall them at will (RCL), still within the program.
Quite simple on a 41. Or maybe I don’t get the logic behind the 50g.

Engineer & Senior IT Executive
Tall-Key HP41CL, CV, CX, 82162A Printer, 82143A Printer, 82160A HP-IL, 2 Card-Readers, Modules, Wand, HP50g.
Find all posts by this user
Quote this message in a reply
06-30-2019, 02:41 PM
Post: #7
RE: HP50g R/S key
Then you use local variables in your program like I did above.
Find all posts by this user
Quote this message in a reply
06-30-2019, 02:56 PM
Post: #8
RE: HP50g R/S key
(06-30-2019 02:41 PM)grsbanks Wrote:  Then you use local variables in your program like I did above.

Yes, I get that.

But what if you WANT/NEED to be prompted for data entry?

Like in this simple HP41 program.


Attached File(s) Thumbnail(s)
   

Engineer & Senior IT Executive
Tall-Key HP41CL, CV, CX, 82162A Printer, 82143A Printer, 82160A HP-IL, 2 Card-Readers, Modules, Wand, HP50g.
Find all posts by this user
Quote this message in a reply
06-30-2019, 03:05 PM
Post: #9
RE: HP50g R/S key
"Want" and "need" are not the same.

If you "want" to do things the "keystroke programming" way on a machine that provides you with a structured language then that's your decision, but you're making life difficult for yourself.

However, you don't "need" to prompt for input in a program that's a port to the 50g of your 41C program. The values prompted for in lines 3, 6, 9, 12 and 15 of your 41C program would be entered into the stack before you run the program. The program would take those values from the stack, place them in local variables and use those local variables to do the calculation.
Find all posts by this user
Quote this message in a reply
06-30-2019, 04:11 PM
Post: #10
RE: HP50g R/S key
(06-30-2019 02:56 PM)Neve Wrote:  But what if you WANT/NEED to be prompted for data entry?

The INPUT command displays a prompt string; the user then enters the value on the command line; and presses ENTER to submit it and continue the program.

If there are several values required at once then the INFORM command can be used to create an input form.

For fixed choices from a predefined (or precalculated) list then there is the CHOOSE command.

A common technique is to write a function that accepts its parameters from the stack so that it can easily be called from within a larger program, but use an input form as a wrapper for when it is called on its own and you want a reminder of what the parameters are.
Find all posts by this user
Quote this message in a reply
06-30-2019, 04:13 PM
Post: #11
RE: HP50g R/S key
(06-30-2019 04:11 PM)BruceH Wrote:  
(06-30-2019 02:56 PM)Neve Wrote:  But what if you WANT/NEED to be prompted for data entry?

The INPUT command displays a prompt string; the user then enters the value on the command line; and presses ENTER to submit it and continue the program.

If there are several values required at once then the INFORM command can be used to create an input form.

For fixed choices from a predefined (or precalculated) list then there is the CHOOSE command.

A common technique is to write a function that accepts its parameters from the stack so that it can easily be called from within a larger program, but use an input form as a wrapper for when it is called on its own and you want a reminder of what the parameters are.

Thank you. I’ll try that too.

Engineer & Senior IT Executive
Tall-Key HP41CL, CV, CX, 82162A Printer, 82143A Printer, 82160A HP-IL, 2 Card-Readers, Modules, Wand, HP50g.
Find all posts by this user
Quote this message in a reply
06-30-2019, 04:43 PM
Post: #12
RE: HP50g R/S key
(06-30-2019 02:56 PM)Neve Wrote:  ...Like in this simple HP41 program.

Bruce responded with the "INPUT" suggestion before I could finish my post Smile. Here's a sample of how that might look:
Code:
«
   "HITS?" "" INPUT STR→
   "WALKS?" "" INPUT STR→
   "HIT-PITCH?" "" INPUT STR→
   "AT BAT?" "" INPUT STR→
   "SAC FLY?" "" INPUT STR→
   → hits walks hitpitch atbat sacfly
   «
      hits
      walks
      +
      hitpitch
      +
      ...
   »
»

Entering the values is a simple matter of pressing the numeric keys needed followed by ENTER, after which the program automatically continues (no need for CONT). The values left on the stack by that series of INPUT steps are then stored in local variables which are then accessible by name in the subsequent « ... » block.

I believe this type of construct provides similar functionality to the 41 code you listed. Instead of pressing R/S after entering the values, you simply press ENTER. The INPUT command has more overhead than PROMPT, but that's needed to support the different object types and to allow for additional processing if needed based on the contents of what was entered.
Find all posts by this user
Quote this message in a reply
06-30-2019, 05:33 PM
Post: #13
RE: HP50g R/S key
(06-30-2019 04:43 PM)DavidM Wrote:  
(06-30-2019 02:56 PM)Neve Wrote:  ...Like in this simple HP41 program.

Bruce responded with the "INPUT" suggestion before I could finish my post Smile. Here's a sample of how that might look:
Code:
«
   "HITS?" "" INPUT STR→
   "WALKS?" "" INPUT STR→
   "HIT-PITCH?" "" INPUT STR→
   "AT BAT?" "" INPUT STR→
   "SAC FLY?" "" INPUT STR→
   → hits walks hitpitch atbat sacfly
   «
      hits
      walks
      +
      hitpitch
      +
      ...
   »
»

Entering the values is a simple matter of pressing the numeric keys needed followed by ENTER, after which the program automatically continues (no need for CONT). The values left on the stack by that series of INPUT steps are then stored in local variables which are then accessible by name in the subsequent « ... » block.

I believe this type of construct provides similar functionality to the 41 code you listed. Instead of pressing R/S after entering the values, you simply press ENTER. The INPUT command has more overhead than PROMPT, but that's needed to support the different object types and to allow for additional processing if needed based on the contents of what was entered.

Oh I see, thanks.
I’ll try playing with these commands.
I guess I just like the “simplicity” of how the 41 behaves and try to replicate that in the 50g.

Engineer & Senior IT Executive
Tall-Key HP41CL, CV, CX, 82162A Printer, 82143A Printer, 82160A HP-IL, 2 Card-Readers, Modules, Wand, HP50g.
Find all posts by this user
Quote this message in a reply
Post Reply 




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