The getMode() Command

getmode.png

Command Summary

Checks the current mode settings.

Command Syntax

getMode(setting)

Menu Location

This command can't be found in any menu besides the command catalog.

Calculator Compatibility

This command works on all calculators.

Token Size

2 bytes

The getMode() command checks any one current mode setting. Just give it the name of the mode setting to check, as a string, and it will give you the current value. For example:

:getMode("Angle")
           "RADIAN"
:getMode("Complex Format")
           "REAL"

The name of the setting is not case-sensitive, but is very typo-sensitive.

In practice, getMode() is almost entirely superseded by setMode() — usually, you don't care about a setting unless you want to change it if it's wrong. In particular, it is silly to do the following:

:If getMode("Angle")≠"RADIAN"
:  setMode("Angle","RADIAN")

In this case, just the setMode() command instruction by itself would have been fine, since changing the mode from radian to radian would've done nothing anyway.

It is also silly to do the following:

:getMode("Angle")→oldmode
:setMode("Angle","RADIAN")
...
:setMode("Angle",oldmode)

It is a noble impulse to try to preserve the old setting and restore it later. However, the same is accomplished more elegantly with (note the { } brackets):
:setMode({"Angle","RADIAN"})→oldmode
...
:setMode(oldmode)

Optimization

Every string like "Angle" or "FLOAT 12" can be replaced by a numerical equivalent (one that is, for some reason, still given as a string, e.g. "3" or "26"). Using these is shorter, and it has the benefit of being international.

See the Table of Mode Settings to look up these numbers, as well as read about what the various mode settings do.

Error Conditions

260 - Domain error happens when a mode setting or value doesn't exist, at least not with this spelling.

Related Commands

See Also

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.