Store and recall display format

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
keithdalby
Posts: 564
Joined: Mon Apr 24, 2017 8:38 pm

Store and recall display format

Post by keithdalby »

I must be really dumb. I cannot figure out how to store the display format (significant figures in particular), change it for part of a program, then recall the previous format again. Can anyone please help?
keithdalby
Posts: 564
Joined: Mon Apr 24, 2017 8:38 pm

Re: Store and recall display format

Post by keithdalby »

Something like RCLFLAG and STOFLAG from the 82180A?
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: Store and recall display format

Post by Thomas Okken »

The information you're looking for is in these six flags:

36 digits bit 3
37 digits bit 2
38 digits bit 1
39 digits bit 0
40 fix or all
41 eng or all

So you can get the digits with something like:
0 FS? 36 8 FS? 36 + FS? 37 4 FS? 37 + FS? 38 2 FS? 38 + FS? 39 1 FS? 39 +

The display mode works like this:
FIX: 40 set, 41 clear
SCI: 40 clear, 41 clear
ENG: 40 clear, 41 set
ALL: 40 set, 41 set
rprosperi
Posts: 1703
Joined: Mon Apr 24, 2017 7:48 pm
Location: New York

Re: Store and recall display format

Post by rprosperi »

keithdalby wrote:
Sun Feb 11, 2018 7:51 pm
Something like RCLFLAG and STOFLAG from the 82180A?
I would support adding these 2 commands as they are universal (applies to all the possible save this or that requests) but they also let a program save machine flag state on entry, change whatever it wants for its own use, then restore settings just before exiting.

@Thomas: Are there any flags whose state save/restore require special handling (i.e. where the suggested usage may cause trouble or unexpected results)? From memory, I have a nagging feeling there are 1 or 2 flags that are best left as-is, when these commands are used from a running program; but I admit, maybe I'm confusing machines or issues here.
--bob p

DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
keithdalby
Posts: 564
Joined: Mon Apr 24, 2017 8:38 pm

Re: Store and recall display format

Post by keithdalby »

Thomas Okken wrote:
Sun Feb 11, 2018 8:18 pm
The information you're looking for is in these six flags
Tremendously helpful, thank you. And thank you for the MENU help. It's working great now. Just want to add the graph manipulation code from another program I wrote into the same program and have a submenu for it, then it's all done and ready to share again (for what it's worth).
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: Store and recall display format

Post by Thomas Okken »

rprosperi wrote:
Sun Feb 11, 2018 8:57 pm
keithdalby wrote:
Sun Feb 11, 2018 7:51 pm
Something like RCLFLAG and STOFLAG from the 82180A?
Are there any flags whose state save/restore require special handling (i.e. where the suggested usage may cause trouble or unexpected results)? From memory, I have a nagging feeling there are 1 or 2 flags that are best left as-is, when these commands are used from a running program; but I admit, maybe I'm confusing machines or issues here.
Well, there are a few flags that are supposed to indicate certain special states the calculator might be in: 45 (solving), 46 (integrating), 53 (input), and 65 (matrix editor). What happens when you mess with those flags? Will weird things happen, or will it crash? I have no idea, to be honest, I'd have to re-read the code. :)

Then there are several flags that aren't stored in the flags array, but are instead emulated using functions. These are marked as VIRTUAL in the flags array. If you want to preserve those, be sure to call the virtual flag handler instead of peeking and poking the flags array.

I think getting and putting all flags at once is too all-or-nothing. Something where you could use bitmasks seems more useful, although also a bit problematic because the 42S bitwise instructions work on 36-bit words (for compatibility with 12-digit octal numbers, I assume) while there are 100 flags...
rprosperi
Posts: 1703
Joined: Mon Apr 24, 2017 7:48 pm
Location: New York

Re: Store and recall display format

Post by rprosperi »

Thomas Okken wrote:
Sun Feb 11, 2018 9:52 pm
Well, there are a few flags that are supposed to indicate certain special states the calculator might be in: 45 (solving), 46 (integrating), 53 (input), and 65 (matrix editor). What happens when you mess with those flags? Will weird things happen, or will it crash? I have no idea, to be honest, I'd have to re-read the code. :)

Then there are several flags that aren't stored in the flags array, but are instead emulated using functions. These are marked as VIRTUAL in the flags array. If you want to preserve those, be sure to call the virtual flag handler instead of peeking and poking the flags array.

I think getting and putting all flags at once is too all-or-nothing. Something where you could use bitmasks seems more useful, although also a bit problematic because the 42S bitwise instructions work on 36-bit words (for compatibility with 12-digit octal numbers, I assume) while there are 100 flags...
Thanks for these comments Thomas. It was the Solving and Integrating flags I (sorta) recalled. They stuck out as I never knew about them...

For limited in-program use I agree bit-mask tweaking is likely better for narrow purposes, but I like the idea of enabling a program to globally restoring the same conditions as before it ran, as this means it does not have to keep track of possibly many different settings (display mode, angular mode, print modes, curve-fit models, etc.) in order to restore things as they were. I frequently find this to be an issue, as most programs 'assume' the same defaults as that author uses. While a bad programming practice, I see it all the time...

Perhaps both have value, but either way, I'd agree some of these flags need to be carefully considered as restoring them en-masse could lead to issues too. In any case, restore should not be performed unless actually saved... leading to some other state status... yeesh, might get messy.
--bob p

DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

Re: Store and recall display format

Post by whuyse »

I just wrote those, as it happens. I include the radix and 1000th separator as well.

STO/RCL Mode
_______________

Recalls and restores the status of FIX/SCI/ENG/ALL, RDX and 1000th's separator

RCLMODE
In:
Out: mode x y z

STOMODE
In: mode
Out: y z t t

Code: Select all

00 { 101-Byte Prgm }
01▸LBL "RCLMODE"
02 36.041
03 ABS
04 CLX
05 XEQ 04
06 ABS
07 CLX
08 28.029
09 X<> ST L
10▸LBL 04
11 STO+ ST X
12 FS? IND ST L
13 ISG ST X
14▸LBL 04
15 ISG ST L
16 GTO 04
17 RTN
18▸LBL "STOMODE"
19 0
20 CF 29
21 BIT?
22 SF 29
23 SIGN
24 CF 28
25 BIT?
26 SF 28
27 CLX
28 16
29 ÷
30 FP
31 STO+ ST X
32 STO+ ST X
33 R↓
34 GTO IND ST T
35▸LBL 00
36 SCI IND ST L
37 RTN
38▸LBL 01
39 ENG IND ST L
40 RTN
41▸LBL 02
42 FIX IND ST L
43 RTN
44▸LBL 03
45 ALL
46 END
I have another version that does SAVEMODE and RESTMODE and uses the STACK matrix, and leaves the whole stack undisturbed. Will post if requested.

Cheers, Werner
*Updated to correct a bug
Last edited by whuyse on Fri Feb 16, 2018 9:11 am, edited 1 time in total.
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
keithdalby
Posts: 564
Joined: Mon Apr 24, 2017 8:38 pm

Re: Store and recall display format

Post by keithdalby »

These are so helpful. I'll cannibalise these for my project later. Thank you.
rprosperi
Posts: 1703
Joined: Mon Apr 24, 2017 7:48 pm
Location: New York

Re: Store and recall display format

Post by rprosperi »

whuyse wrote:
Mon Feb 12, 2018 8:56 am
I have another version that does SAVEMODE and RESTMODE and uses the STACK matrix, and leaves the whole stack undisturbed. Will post if requested.
Yes, please do post. So STACK is a matrix used as global storage for all the settings? Very nice! If it's feasible to also include angular mode, this would achieve preserving most of the commonly changed settings. I did not foresee a means to do this in FOCAL and still preserve the stack. Impressive Werner. Thanks for sharing this.
--bob p

DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
Post Reply