Update: code removed as it contained bugs (yes, plural. I'm slipping). See a few posts down for a much improved version.

Hi Bob,
I was referring to this, the POP/PUSH stack program that needs a 4-column matrix to hold the stack levels.
The following program uses that STACK matrix, and will SAVE and RESTORE the mode, and keep the stack - including LastX - intact while doing so. Drawback is that the stack may not hold matrices or complex numbers - use RCLMODE and STOMODE then.
It can be easily adapted to also take into account flags 42 and 43 that hold the DEG/RAD/GRAD mode.

So, you do
XEQ "SAVMODE"
<change things>
XEQ "RSTMODE"

Since the STACK matrix is also used for PUSHing and POPping the stack, make sure there are an equal number of both in the <change things> part

Cheers, Werner

Last edited by whuyse on Fri Feb 16, 2018 8:13 am, edited 1 time in total.

Here's my latest concoction.
I decided to focus solely on Save & Restore functionality, but without use of the STACK matrix.
So, the following programs Save and Restore the Mode (well, display mode FIX/SCI/ENG/ALL, DEGRAD, Thousands separator, comma or decimal point, Rectangular/Polar and Complex or Real results).
Both programs leave the stack intact, whatever it may contain (matrices, complex numbers, ..). Both use the variable 'Mode' and one or two temporary variables that are deleted on exit. Restoring the mode leaves the 'Mode' variable intact.

This is not only extremely useful for everyday programming, but it also employs advanced techniques with variables and system programming, plus as usual, some lessons in efficient stack juggling.

Though having this provided by new system commands might be a tiny bit more transparent, this is close enough for me and also serves as an instructional tool. I withdraw my request for new save/restore state commands.