Click to See Complete Forum and Search --> : Switching between two type of units


April 21st, 1999, 03:19 PM
Hi,

In my application I have two type of units - english and northamerican style i.e, lbs and Kgs ( for weight, etc.). Is there any easier way to toggle between the two types rather than writing code for each??

I will appreciate your hints and ideas.
Thanks.

John Holifield
April 21st, 1999, 04:34 PM
You might try something like this: Carry a variable of some type in your program to tell you what unit system you want to work with. Then add a 'conversion factor' to all your calculation routines. Write all your calculation code but replace Units with (Units * Conversion Factor). Then all you have to do is check which unit system you are in and adjust the conversion factor appropriately.