Depending on how you would use this, you may choose not to have a script.
If you make three new fields (FieldAcm, FieldBcm, FieldCcm) as calculation fields returning numbers, you can simply define the fields as
= FieldA * 2.54 for field Acm
= FieldB * 2.54 for field Bcm
This will work well for you with no script.
If, however, you will perform searches on this field, you may want to avoid this calc field since it may slow your searches. If this is the case, launch an OnObjectModify script on each field that runs a script like:
SetField (Table::FieldAcm ; Table::FieldA * 2.54)
Is this what you're after?
This is SO helpful. Thank you so much for your quick reply. This makes sense to me up to the point where I need the new inches fields and the centimeter fields to "see" each other. How do I connect the two? Thanks again!!
If you chose to make the cm field a calc field, in the same table, the "seeing" is done in the calculation you define.
FieldAcm = FieldA * 2.54
If doing it via script, the fields don't need to "see" each other. The script takes the value from FieldA, multiplies it by 2.54 then shoves it into the other field (FieldAcm).
no connection is needed outside of this. There is no relationship connection needed in order to do what you describe since the fields are already on the same record in the same table.
You rock so hard. THANKS! Will post again if I get stuck!
Okay! Everything is performing beautifully. Thanks so much!!
EEK! One last question! Is there a way to limit the centimeters to only two numeric values past the decimal? Thanks!
If you care about the precision then you wouldnt change the real result but rather format the calc field to only show 2 decimal places. Click the field and look under numer formatting.
If you only want it to return two decimal places then use Round ( FieldA * 2.54; 2 ) or Truncate ( FieldA * 2.54; 2 ), depending on what you like.
Thanks, Mr. Vodka! That was really helpful. Here is my final question (I hope!):
How do you get the formula to behave properly when using fractions?
Example: 8 inches converts nicely to 20.32 cm. However, 8 1/8 converts to 2077.72 and I want it to read 20.77.
Any ideas? I really don't want to convert the fractions to decimals if at all possible (I really do want 8 1/8" vs. 8.125").
I dont quite understand what you are asking.
8 1/8 is actually 8 + 1/8 or 65/8.
I have no clue where you are even getting the 2077.72 figure from. Shouldnt it be 20.6375?
818 inches = 2077.72 cm
It looks like the typed fraction either does not have, or is ignoring the /
Lol. Should have checked that.
Yes that would be the typical result if that was put in a number field. If you are going to use fractions you should probably enter it into a text field. Then you can probably modify your calc to be something like:
Round ( Evaluate ( Substitute ( Trim ( YourMixedNumberField ); " "; "+" ) ) * 2.54; 2 )