How to use PGMMENU & VARMENU

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
Post Reply
richmit
Posts: 18
Joined: Tue Feb 16, 2021 2:51 am

How to use PGMMENU & VARMENU

Post by richmit »

Hi,

I'm working on a program to select a MVAR function and a variable in the selected function -- i.e. I want to pick a function to plot and a an independent variable. I have two questions:

1) How can I display a prompt when PGMMENU is working? My code below just shows a blank line above the menu. I'm using free42 3.0.2

2) How can get the VARMENU-like behavior of the built in integration application -- i.e. where you press a variable and it is selected instead of the double press behavior used by the solver and VARMENU?

Code: Select all

LBL "PICF"
FUNC 01
EXITALL
"Pick Function"
AVIEW
PGMMENU 
STOP
ASTO "FUNC"
EXITALL
VARMENU IND "FUNC"
STOP
ASTO "IVAR"
EXITALL
"F: "
ARCL "FUNC"
├"("
ARCL "IVAR"
├")"
AVIEW
RTN
END
Thomas Okken
Posts: 877
Joined: Tue May 02, 2017 5:48 pm
Location: United States
Contact:

Re: How to use PGMMENU & VARMENU

Post by Thomas Okken »

richmit wrote:
Thu Apr 01, 2021 8:35 pm
1) How can I display a prompt when PGMMENU is working? My code below just shows a blank line above the menu. I'm using free42 3.0.2
It looks like PGMMENU is clearing the display. That's a bug, it's not supposed to do that. But as a work-around, you can use AVIEW or PROMPT after PGMMENU.

(Update: Yep, there was a line in the PGMMENU logic that explicitly cleared the top row of the display. I don't know why I put that there; VARMENU doesn't do that, and neither should PGMMENU. I removed it and so PGMMENU will behave more reasonably in the next Free42 release.)
richmit wrote:
Thu Apr 01, 2021 8:35 pm
2) How can get the VARMENU-like behavior of the built in integration application -- i.e. where you press a variable and it is selected instead of the double press behavior used by the solver and VARMENU?
You can't. The "select" behavior only happens immediately after the STO behavior, so if you want to select a variable without storing any data, you have to press the menu key twice (which means you are storing something, just not overwriting anything important, hopefully).
Last edited by Thomas Okken on Fri Apr 02, 2021 12:06 am, edited 1 time in total.
whuyse
Posts: 128
Joined: Thu Dec 21, 2017 1:23 pm

Re: How to use PGMMENU & VARMENU

Post by whuyse »

Exactly. 42S behaviour..
See here: https://www.hpmuseum.org/forum/thread-16574.html for an example of the use of PGMMENU.
Cheers, Werner
42S #3249S01123
DM42 #00345
DM41X #01215
richmit
Posts: 18
Joined: Tue Feb 16, 2021 2:51 am

Re: How to use PGMMENU & VARMENU

Post by richmit »

Thomas & Werner;

Thank you!

A bug! How exciting. Usually when computers don't do what I want, I'm doing something wrong!

Flipping the order got me working -- didn't think about that because it is still strange to me that menu commands don't halt execution.

A VARMENU1 function that acted the way the integration variable menu works would be a neat feature.

Anyhow, here is a little program that will do sums & products, and works almost the same way the built in integration works. The log option computes the sum/product of the log of the values.

Code: Select all

LBL "PICF"
FUNC 01
EXITALL
PGMMENU 
"Pick Function"
AVIEW
STOP
ASTO "_EQ"
EXITALL
VARMENU IND "_EQ"
"Set Var; "
├"Pick Free Var"
AVIEW
STOP
ASTO "_EQX"
EXITALL
"F: "
ARCL "_EQ"
├"("
ARCL "_EQX"
├")"
AVIEW
RTN
END

LBL "PSUM"
CF 02              
XEQ "PICF"
LBL 01            @@@@ Page 1 of menu SSUM
CLMENU
"LLIM"
KEY 1 XEQ 02
"ULIM"
KEY 2 XEQ 03
"STEP"
KEY 3 XEQ 04
"LOG"
KEY 4 XEQ 07
FS? 02
"Σ ln"
FC? 02
"Σ"
KEY 5 XEQ 05
FS? 02
"π ln"
FC? 02
"π"
KEY 6 XEQ 06
KEY 9 GTO 00
MENU
STOP
GTO 01
LBL 00
EXITALL
RTN
LBL 02               @@@@ Action for menu key LLIM
STO "LLIM"
"LLIM: "
ARCL ST X
AVIEW
RTN
LBL 03               @@@@ Action for menu key ULIM
STO "ULIM"
"ULIM: "
ARCL ST X
AVIEW
RTN
LBL 04               @@@@ Action for menu key STEP
STO "STEP"
"STEP: "
ARCL ST X
AVIEW
RTN
LBL 07               @@@@ Action for menu key log
FS?C 02
RTN
SF 02
RTN
LBL 05               @@@@ Action for menu key SUM
SF 01
GTO 30
LBL 06               @@@@ Action for menu key PRODUCT
CF 01
GTO 30
LBL 30
@@@@ Default LLIM & STEP to 1 if unset
1
SF 25
RCL "LLIM"
FC?C 25
STO "LLIM"
SF 25
RCL "STEP"
FC?C 25
STO "STEP"
@@@@ Check for bad LLIM, ULIM, & STEP
RCL "LLIM"
RCL "ULIM"
X>Y?
GTO 31
"ERR: LLIM ≥"
├" ULIM"
AVIEW
RTN
LBL 31
RCL "STEP"
X>0?
GTO 32
"ERR: STEP ≤ 0"
AVIEW
RTN
LBL 32
@@@@ Sum/Prod it up
FS? 01
0
FC? 01
1
LSTO "SoP"
RCL "LLIM"
STO IND "_EQX"
LBL 33
CLA
ARCL "_EQX"
├"="
ARCL IND "_EQX"
AVIEW
1
SF 25
XEQ IND "_EQ"
FS?C 25
GTO 41
"ERR: Func Eval"
AVIEW
RTN
LBL 41
FC? 02
GTO 42
SF 25
LN
FS?C 25
GTO 42
"ERR: Bad Log"
AVIEW
LBL 42
FS? 01
STO+ "SoP"
FC? 01
STO× "SoP"
RCL "STEP"
RCL IND "_EQX"
+
STO IND "_EQX"
RCL "ULIM"
X≥Y?
GTO 33
RCL "SoP"
FS? 01
"SUM: "
FC? 01
"PROD: "
ARCL ST X
AVIEW
RTN
END

Post Reply