Before you consider a script, think in terms of data and relationships.
You can set up a table of conversion factors such as 2.54 cm in a pair of fields and 1 in in another pair of fields in the same record.
You can then set up a relationship that matches by desired units (input and output) with a calculation that then references the correct value to use to convert from one to the other. This method can work for any unit conversion where 0 represents the same quantity in both measurement systems. (Can't use it for temperatures)
CalculationTable::UnitsImperial = ConversionFactors::unitsimperial AND
CalculationTable::UnitsMetric = ConversionFactors::UnitsMetric
Then CalculationTable::ImperialValue * ConversionFactors::MetricFactor
Can compute the metric equivalent. In our example, 2 inches * 2.54 cm/in yields 3.08 cm
So I created three fields Length, Height, and Width. Would I place the calculations in each field?
What else did you create? 3 separate fields might require relationships matching different fields to the table of conversion factors. If you use one record for each dimension, this is not needed.
But note that I've described pairs of fields, one for the measurement and one for the units used. You'd match records by units in order to access the correct conversion factor. If you always use the same units of measure, this would not be needed--you wouldn't then need a table of conversion factors as you'd use the same factor each time. So it would help to describe what you want in more detail.
I have to input measurements in three separate fields length, height, and
width; using imperial measurements.
Next I need to convert each length, height, width into metrics.
I would create a Custom Functions that did all this for me
I would call the function Conversion and have 3 Parameters
Parameter 1 = Value
Parameter 2 = UnitFrom
Parameter 3 = UnitTo
Then I would just to Case() function in my Customer function that calculated my value into asked Unit type
UnitFrom = "Fahrenheit" and UnitTo = "Celsius"; Value * ((68 - 32) * 5/9)
UnitFrom = "Ounce" and UnitTo = "Gram"; Value * 28,3495231
And your result will be what you ask for
Not to spoil your fun in creating one yourself, but here is a metric conversion file I created some years ago. I'm happy to provide it free to fellow developers, for what it's worth.
If you are always converting inches to mm, say, then you can simply create 3 calculations; LengthMetric = LengthImperial *25.4, etc.
You seem really smart in using File Maker.
So I have three fields Length Height Width for Imperial
Then I have three fields Length Height Width for Metrics
I need them both to interact so if I key in imperial measurements the metric measurements will calculate automatically. How can I do this?
What imperial units are you entering? Always inches? Sometimes feet and inches? Yards, miles, furlongs...?
How do you want the output to look? Always in mm? Metres?
If you are entering anything other than inches (or round feet or yards, say) I would have several fields, or at least a very disciplined entry format.
If you are going to enter a dimension in feet and inches, you could have two fields for the imperial and one for the resulting metric conversion.
So. for example:
Length_Ft = 2
Length_Ins = 6
Length_mm (by Calculation) = ( (Length_Ft * 12) + Length_Ins ) * 25.4
You could enter the imperial length in one field, in a strict format, like 2-06, then parse out the characters before, and the characters after, the '-,' and use them in the same calculation.
I suggest 2-06 for 'six inches' to avoid the potential for confusion whether 2-1 means 'two feet one inch' or 'two feet ten inches'.
inches and meters is what i am using
If those are the only units that you need, then you don't need a table nor a relationship. Do you always input imperial and need to always get metric? if so, calculations defined on your metric fields are all that you need here and all you need is the conversion factor for inches to meters--a value easily web searched or you can calculate it from the inches to Cm factor already posted here.
1 inch = 2.54 cm/in (1m/100cm) = .0254 m/inch
and the math comes to Imperial Measurement * 0.254
There are any number of ways to implement that calculation.
Length in = Length cm * 2.54 This is the calculation I am using. When I type a number in the inches field the number in the cm field is always 0.
My boss wants the cm fields calculated automatically.