Tips & Tricks

GlassCalc is full of features that may be less than obvious at first glance. Here’s a few tips and tricks to make use of those features.

Save your calculation history

By default, GlassCalc forgets all your calculations when you close and reopen the program. To make GlassCalc remember them, bring up the settings window from Options > More Settings and check Save history between program runs. You can also set how many results GlassCalc remembers. If you set this to -1, GlassCalc will save everything, which could cause the program to slow down if you don’t periodically clear the list.

Perform unit conversions

GlassCalc can perform unit conversions with the help of the aptly named Units program. First, download and install Units for Windows. If you use the default installation directory, GlassCalc will configure itself automatically. If not, you need to find units.exe and copy its location to Options > More Settings > Path to units.exe. Make sure Options > More Settings > Enable unit conversion is checked.

The syntax for unit conversions is very simple. Just type the number or expression you want to convert followed by the unit you want to convert from, the word “to”, and the unit you want to convert to. For example, to convert 100 meters to inches, enter 100 meters to inches. Be careful with order of operations though. Unit conversions happen last, so 1 + 2 m to cm means (1 + 2) m to cm. If you wanted to convert only the 2, write the expression as 1 + (2 m to cm).

Edit extensions.ini

A number of these tricks involve editing a settings file named extensions.ini which can be edited with any text editor.  To open this file, open GlassCalc and bring up the settings window from Options > More Settings.  Go to the Extensions tab.  There are two columns labeled Global Extensions and User Extensions.  Global extensions apply to all users while user extensions apply to only the current user, but both can make the same changes.  On Vista and Windows 7, editing global extensions requires administrator privileges, so  unless you are setting GlassCalc up for multiple users on the same computer, editing user extensions is easier.

If both columns say “extensions.ini” does not exist, click Create extensions.ini under the User Extensions header.  Otherwise, click Edit extensions.ini.  Your text editor should open with the file loaded.

The global extensions.ini is located in the GlassCalc installation directory, and the user extensions.ini is located at %AppData%\GlassCalc\extensions.ini.

Define a new constant

GlassCalc comes with a few constants defined, but you can add your own.

Open extensions.ini.  There should be a section that looks like this:

[Constants]
pi = Math.PI
e = Math.E
. . .

Add lines under this section to define constants.  Each line should be in the format name = value.  Name is case-sensitive and can contain letters, numbers, and underscores, but it cannot start with a number.  Value is either a decimal number (exponential format is supported) or any numeric .NET field/property/constant defined in mscorlib.dll.  If the value is not defined within the System namespace, the full namespace must be given. If you aren’t familiar with programming for .NET, you can safely ignore that second part and just use numbers.

For example to add Planck’s constant to the list, add this line under the [Constants] section:
Planck = 6.6260689633e-34.

Define a scale factor

Some calculations would be easier if you could write 1K instead of 1000 or  2.5M instead of 250000.  You could define these as constants, but because of order or operations, 1/1K would be evaluated as 1/1*1000 which comes out to 1000, not 0.001!    For this, GlassCalc has scale factors which can be defined in extensions.ini.

Open extensions.ini.  There should be a section that looks like this:

; [ScaleFactors]
; m = 1e-3
. . .

Uncomment the [ScaleFactors] section (remove the semicolon from the beginning of the line).  If this section isn’t present, add it.  Add lines under this section to define scale factors. Scale factors are suffixes placed on numbers to scale them by some value.  Each line should be in the format suffix = scale.  Suffix is the text placed at the end of a number and is case-sensitive.  Scale is the value the number should be multiplied by. This can be a decimal number or .NET value just like with custom constants.

To make 1K mean 1000, we’ll define a suffix K with a scale of 1000.  Add this line under the [ScaleFactors] section:
K = 1000

If you want the suffix to ignore case, add /i to the end of the suffix like this:
K/i = 1000

Suffixes can be multiple characters as well, like this:
mol = 6.022142e23

Use % for percentages

Normally, the percent sign is used as the modulus division operator, but if you frequently perform calculations with percentages, it might be useful to write 100% and have it mean 100 percent.  This can be done with a scale factor.  Scale factor suffixes aren’t limited to alphabetic characters (in fact, they use regular expression syntax, but anything complicated may confuse the ini parser or the math parser and lead to some very unexpected behavior).

Add this line to the [ScaleFactors] section extensions.ini and make sure there is no semicolon at the beginning of the [ScaleFactors] line.
% = 0.01

Now you can use percentages.  Keep in mind that you will now need to put a space between the end of a number and the % sign if you want to use the modulus operator.  Also, this tweak will not make GlassCalc evaluate expressions like 100 + 5% as “100 + 5 percent of 100”. Instead, it will evaluate 100 + 5% as “100 + 0.05”.  For this case, you can use 100 * 105% instead.