Showing posts with label messages. Show all posts
Showing posts with label messages. Show all posts

Saturday, October 11, 2025

RPN Calculators: INPUT vs PROMPT

RPN Calculators: INPUT vs PROMPT


Later RPN keystroke programming calculators are able to display alphabetic messages and store to variables for alphabetic names.


HP 32S, HP 32SII, HP 33S, HP 35S, DM32

HP 41C (all variants), DM41X

HP 42S, DM42, DM42n, Free 42

Single letter variable names

Numeric-named variables only

Both numeric-named variables and alphabetic (and alphanumeric) variable names. Alphabetic and alphanumeric named variables are enclosed in quotes (alpha strings) well stored and recalled and take additional memory.

Can display messages by setting Flag 10 and using the equation feature to type messages

Can display messages and prompts

Can display messages and prompts


Two common ways to cue the user to enter values are the INPUT and PROMPT commands.


The INPUT Command: HP 32 and HP 42S (and Swiss Micros/emulator equivalents)


Note: The INPUT command is not available in the HP 41C’s command set.


General syntax: INPUT var


When an INPUT command is encountered, the screen will display [var]?= on the X stack.


Example:

INPUT R displays R? [previous value stored in R]


HP 32 Family: The variable is a single-letter name or the indirect variable i.

HP 42S Family: A custom alpha variable, a numeric-named variable (i.e. 00, 01, 02, etc.), indirect variables, or the stack levels X, Y, T, Z, or L (last argument).


The INPUT has the double benefit of storing whatever is entered into the variable asked for. INPUT will also show the previously stored value, so we can just accept it by pressing R/S to keep the old value.


Example: Volume of a Cone


HP 32 family

HP 42S family

V01 LBL V

V02 INPUT R

V03 INPUT H

V04 π

V05 RCL R

V06 x^2

V07 ×

V08 RCL H

V09 ×

V10 3

V11 ÷

V12 RTN


No quotes are needed for alphabetic variables.



00 {30-Byte Prgm }

01 LBL “VCONE1”

02 INPUT “R”

03 INPUT “H”

04 PI

05 RCL “R”

06 x↑2

07 ×

08 RCL “H”

09 ×

10 3

11 ÷

12 RTN


We could use variables 00 and 01 (for example) for radius and height, respectively, except the input command prompt will show “R00?” or “R01?” which may not be user-friendly.


The INPUT does not replace the contents of the alpha register.


If we want the alphanumeric/alphanumeric variables (“R”, “H”) to be erased, we could have inserted CLV “R” and CLV “H” at the end, but that will erase the value associated with them.



The PROMPT Command: HP 41C and HP 42S (and Swiss Micros/emulator equivalents)


Note: The PROMPT command is not available on the HP 32S family.


General Syntax:

alpha string”

PROMPT

STO var


The alpha string is displayed until something, usually a numeric value, is entered. Unlike the INPUT command, the PROMPT does not automatically store the entered value into a variable. Therefore, if you want to use the value for future use, a STO (store) command must be used following the prompt.


Let’s take our volume of the cone example again:


HP 41C family

HP 42S family

01 LBL “VCONE2”

02 ^T RADIUS?

03 PROMPT

04 STO 00

05 ^T HEIGHT?

06 PROMPT

07 STO 01

08 PI

09 RCL 00

10 X↗2

11 *

12 RCL 01

13 *

14 3

15 /

16 RTN



R00 = radius

R01 = volume

00 { 40-Byte Prgm }

01 LBL “VCONE2”

02 “RADIUS?”

03 PROMPT

04 STO 00

05 “HEIGHT?”

06 PROMPT

07 STO 01

08 PI

09 RCL 00

10 X↑2

11 ×

12 RCL 01

13 ×

14 3

15 ÷

16 RTN



R00 = radius

R01 = volume


With PROMPT, I like to use the numeric-named memory registers, but we can use alphabetic or alphanumeric registers as well.


HP 32SII/DM32: Simulating PROMPT with Flag 10


Even though the HP 32SII does not have a PROMPT command, we can kind of simulate it by using the equation message feature.


To set flag 10: [ |→ ] [ × ]* (FLAGS), { SF }. [ . ] [ 0 ]

To clear flag 10: [ |→ ] [ × ]* (FLAGS), { CF }. [ . ] [ 0 ]

We have to use the decimal point key in order to access flags beyond 9.

(*HP 35S: [ ←| ] [ ↑ ] (FLAGS))


HP 32SII/33S/35S/DM32


W01 LBL W

W02 SF 10

W03 “=RADIUS”

W04 STO R

W05 “=HEIGHT”

W06 STO H

W07 CF 10


W08 π

W09 RCL R

W10 x^2

W11 ×

W12 RCL H

W13 ×

W14 3

W15 ÷

W16 RTN


Turn message mode on

Enter as an equation =RADIUS

Enter radius and press [R/S]

Enter as an equation =HEIGHT

Enter height and press [R/S]

Turn message mode off, so equations can operate normally



Note: Equations are NOT on the original HP 32S.



I hope you find this helpful.


Eddie


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


The author does not use AI engines and never will.

Sunday, November 15, 2020

HP 41C and DM41: Operations by Test, Messages, Block Storage

 HP 41C and DM41: Operations by Test, Messages, Block Storage  


The programs are inspired from a great calculator resource, "Calculator Tips & Routines Especially For The HP-41C/41CV", edited by John Dearing (see source below).   


Operations by Test


One of the tips presented is the selection of one of two opposite arithmetic operations based on a comparison between X and Y values.  This tip was provided by Bill Kolb (tip 2-7).  They are:


X?Y

CHS  (subtract if test is true)

+   (add if test is false)


X?Y

1/X  (divide if the test is true)

*  (multiply if the test is false)


X?Y

1/X   (take the root if the test is true)

Y↑X  (take the power if the test is false)


The following programs uses the test X<Y:


TESTAS:  X<Y  (subtract, y - x),  X≥Y (adding, y + x)


(^T represent the beginning of an alpha string)


01 LBL^T TESTAS

02 X<Y?

03 CHS

04 + 

05 END


Example:  

45, 13, XEQ TESTAS returns 32  (45 - 13)

13, 45, XEQ TESTAS returns 58  (13 + 45)


TESTMD:  X<Y  (divide, y/x),  X≥Y (mulitply, y * x)


01 LBL^T TESTMD

02 X<Y?

03 1/X

04 * 

05 END


Example:  

45, 13, XEQ TESTMD returns 3.4615  ( ≈ 45 / 13)

13, 45, XEQ TESTMD returns 585  (13 * 45)


TESTPR:  X<Y  (root, y^1/x),  X≥Y (power, y^x)


01 LBL^T TESTPR

02 X<Y?

03 1/X

04 Y↑X 

05 END


Example:  

49, 3, XEQ TESTPR returns 3.6593  ( ≈ 49 ^ 1/3)

3, 49, XEQ TESTPR returns 2.3930E23  (≈ 3 ^ 49)


Messages


With the use of AVIEW during a loop, you can display a loop up to 12 characters while the loop is running.   A CLD (clear display) is added after the loop's completion to clear the alpha display and show the stack. (tip 2-25)


The program TESTSUM adds a message while the 41C is summing numbers from 1 to X.   While this is not the most efficient way to tackle the problem, this illustrates the use of messages.  


01 LBL^T TESTSUM

02 STO 01

03 0

04 STO 02

05 LBL 01   // loop begins

06 RCL 01

07 ST+ 02

08 ^T ADDING...  // message

09 AVIEW   // display the message

10 DSE 01

11 GTO 01

12 CLD  // clear display

13 RCL 02

14 END


Example:

50, XEQ TESTSUM  

Display: ADDING..., then 1275


Block Storage


You can use indirect storage and the stack to store a constant in a block of consecutive storage registers.  A sample loop:


LBL %%

STO IND Y

ISG Y

GTO %%


Where %% is a label, and the loop variable is B.EEE  (B:  beginning register, E:  ending register) stored in this case, Stack Y.  (tip 10-1)


The program LOADBLK, prompts the user enter the value, beginning register number, and ending register number.


01 LBL^LOADBLK

02 ^T VALUE

03 PROMPT

04 STO Z     // keystrokes:  [ STO ]  [ . ]  ( Y )

05 ^T R%% BGN?

06 PROMPT

07 ^T R%% END?

08 PROMPT

09 1E3

10 /

11 +

12 STO Y  

13 RDN   // R↓

14 X<>Y

15 LBL 01

16 STO IND Y   // keystrokes:  [ STO ] [ shift ] [ . ] ( Y )

17 ^T STORING...    // message

18 AVIEW

19 ISG Y    // keystrokes:  [ shift ] ( ISG ) [ . ] ( Y )

20 GTO 01

21 ^T DONE

22 AVIEW

23 PSE

24 CLD

25 END


Try this:

Store π in R00 to R03 and e^1 in R04 to R07.

 

Results:  (Fix 4)

R00:  3.1416

R01:  3.1416

R02:  3.1416

R03:  3.1416

R04:  2.7183

R05:  2.7183

R06:  2.7183

R07:  2.7183


Source:


Dearing, John.  "Calculator Tips & Routines Especially for the HP-41C/41CV"  Corvallis Software, Inc.   Corvallis, OR.  1981 


Link on HP41.org (account needed):  http://www.hp41.org/LibView.cfm?Command=View&ItemID=320



Eddie


All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Numworks (Python): Determining Earth’s Acceleration of Gravity

Numworks (Python): Determining Earth’s Acceleration of Gravity Introduction Note: We will only be using SI units on this blog en...