UnitConv


UnitConv is © Chris Johnson, 1992-1999

Unit convert is a small application that allows the interconversion of a wide range of units, for example, feet into cm or m, etc.. A full listing of the default conversions may be browsed. The application also includes a binary to octal to hexadecimal to decimal converter.

Full interactive help is provided when the !Help application (or its equivalent) is active.

When this application is run, by double clicking on it in a directory display, it's icon is installed on the iconbar.


The iconbar icon

Clicking SELECT on the iconbar icon will open the main unit conversion window. This is actually a toggle action, since if the main window is open, it will be closed. This is useful if the window is buried beneath other windows. Clicking twice with SELECT on the iconbar icon will have the effect of bringing the window to the top of the stack.

Clicking ADJUST on the iconbar icon will open the binary/octal/hexadecimal/decimal window. This is also a toggle action, so the window will be closed if it is already open.

The iconbar icon menu

The iconbar menu has five entries.

Info

Sliding right off this option opens the standard application information window. Further information may be obtained by using the !Help application.

Convert units...

This is the same as clicking SELECT on the iconbar icon, which will open the main unit conversion window. There is no toggle action when using this method. If the window is already open, then no action occurs. Details of this window are described below.

Bin to hex...

This is the same as clicking ADJUST on the iconbar icon, which will open the binary/octal/hexadecimal/decimal window. There is no toggle action when using this method. If the window is already open, then no action occurs. Details of this window are described below.

Gases...

This opens a dialogue that allows the calculation of collision frequencies, velocities, and mean free paths of gaseous molecules. Details of this window are described below.

Quit

This simply quits the application, removing the application icon from the iconbar.


The unit conversion window

This window can be opened either by clicking SELECT on the iconbar icon, or by using the iconbar icon menu. The layout of the window may be considered in two parts.

The left hand side of the window contains the fields into which the values of the units to be converted are entered, and the converted results are displayed. In version 2, there may be up to eight fields here. The conversions are carried out in real time as you type, and the equivalent values in all the units are displayed.

The right hand side of the window allows the type of units being converted to be changed. Version 2 allows up to nine types of units to be current at any one time. The available conversions are displayed and clicking a particular radio icon makes those units the active ones to be converted. Further selections of conversions are available from the menu button at the bottom right of the window.

A wide range of units are supplied by default, but if these are insufficient, then it is possible to add, or customise, the units. This is explained below.


The bin to hex conversion window

This window can be opened either by clicking ADJUST on the iconbar icon, or by using the iconbar icon menu. The layout of the window needs little comment. There are four fields, into any one of which you can type the number, in appropriate format, and the converted values are shown in the other fields. I think I have things set up so that only the digits/symbols which are used to represent a particular format may be typed into the corresponding field. The range of values that are legal correspond to those of a four byte (32 bit) word representing an unsigned integer. Values falling outwith this range are trapped, and an error message is raised.


The gases window

You may enter values for the temperature of the gas, the pressure of the gas, the size of the molecule, and the relative molar mass into the appropriate icons and then click on Calculate. Pressing RETURN will be the same as clicking Calculate. Use TAB or the up/down arrow keys to move to each writable icon in turn.

If you have entered values for all four parameters, then the following values will be calculated.

The program tries to be intelligent about what to calculate. For example, the velocities require only the temperature and the molar mass to be entered, whereas the mean free path calculation requires temperature, pressure, and size of molecule. The program calculates what it can, and leaves the result fields blank if there is insufficient input data for that calculation. Temperature is always entered as kelvin. If a temperature is not entered, then an error message is generated. Menu buttons are provided in this window to allow you to change the default units used for pressure (atmosphere, N/m2, and torr) and size (pm, nm, and m), and to enter the size either as the diameter of the molecule, or as the cross sectional area. If you choose to enter the size as a diameter, the program assumes the molecule is spherical. We are dealing with the collision cross-section, which is effectively PI x diameter2, since the distance between centres of colliding molecules (of the same type) is 2 x radius.

The window remains on-screen until explicitly closed.

Some Useful Data

Collision cross-sections/(nm)2 for a selection of molecules

He 0.21 Cl2 0.93
Ne 0.24 CO2 0.52
Ar 0.36 SO2 0.58
H2 0.27 CH4 0.46
N2 0.43 C2H4 0.64
O2 0.40 C6H6 0.88


Customisation of the conversions

To allow the conversions to be customised to each users preference, the data is now held in a text file, which is read by the application when it initialises. The file may therefore be modified in any text editor. The format of the file must be carefully adhered to, otherwise errors will be generated. If an error occurs, then the application will use a default set of conversions. A full description of the file format is given below.

To edit the file, double click on !UnitConv while holding down the SHIFT key. This will open the application directory. Within this directory, there is a text file named unitsdata. Make a backup copy of this file before attempting to make any changes. Load unitsdata in to your text editor, either by dragging to the editor iconbar icon, or by double clicking SELECT on the file icon. After making your changes, simply save the text file back. The next time !UnitConc is run, the new data will be used.

File format

Examining the unitsdata file in a text editor should show the format to be, I hope, simple and obvious. In the following table, the file entries are shown on the left, while an explanation is given on the right.

#UnitConv:version 1 This must be the first line, and is used to confirm it is the correct file, and to identify the version of the file format (in case it changes in some later incarnation of the application).
#this is a comment Any line starting with the hash (#) symbol, other than the first line, will be treated as a comment and will be ignored. Blank lines will also be ignored, so this helps the readability of the file.
total_groups:2 The integer (in this case 2) identifies the number of different conversion groups that will appear in the menu available from the menu button at the bottom right of the main conversion window. Note that there will always be an additional menu item (special) available as well. These conversions are hardcoded into the application, because they involve conversion algorithms more complex than simple multiplication and division by a constant factor.
group_title:Common This is the first menu item, and the text to the right of the colon will appear in the menu exactly as in the file.
group_entries:8 The number of radio icons that will be displayed in the right half of the conversion window whenever that particular menu item is selected. Version 2.00 of UnitConv allows a maximum of 9 icons.
group_item: This identifies the start of a set of conversions.
Length,5
We now have the data for a set of conversions. The first line contains the text that will be displayed against the radio icon in the top right of the main window, followed by the number of different units in the group. A corresponding number of fields will be displayed in the left half of the main window. The data pairs must always be comma separated. Version 2.00 of UnitConv allows a maximum of 8 fields.
cm,100
metre,1
in,39.3700787
ft,3.28083989
mile,6.21371192E-4
The actual units, together with the factors required to interconvert. I think the easiest way of doing this is to select one of the units as the "base", giving it a factor of 1, and then each of the other units will have a factor corresponding to the number of those units in 1 base unit. For example, there are 100 cm in 1 m, 39.3700787 inches in 1 m, 3.28083989 ft in 1 m, and so on. All arithmetic uses double precision, although the result of the conversion is rounded to 5 figures. Large or small conversion factors can be entered in scientific format, although the E must be upper case. The number of data pairs here must correspond to the number already declared in the first line of the group_item data.
group_item:
Time,4
seconds,86400
minutes,1440
hours,24
days,1
There then follows further groups of data, in the same format as described above. The number of these groups must correspond to the number declared in group_entries.
 

If the total number of groups initially declared (total_groups) is greater than 1, then the whole data structure repeats, for however many groups in total there are.

A full listing of the default conversions and units is attached.


Back to download page