shredded Posted September 8, 2016 Posted September 8, 2016 I have two fields: Centimeters and Inches. I am trying to type in one (and vise versa), example (CM): 55-58 and then auto populate (IN) to 21.65-22.83. I was thinking using left or right function, but maybe there will be 3 or more digits in between the (-) symbol. What would be a good way to identify those digits in this case, so that I can apply the conversion vs script? Thanks
jbante Posted September 8, 2016 Posted September 8, 2016 Use substitute to convert the hyphen to a return, then you can get the different numbers with GetValue: Let ( [ _values = Substitute ( Table::field ; "-" ; ¶ ) ; _left = GetValue ( _values ; 1 ) ; _right = GetValue ( _values ; 2 ) ; ] ; /* ... */ )
comment Posted September 8, 2016 Posted September 8, 2016 (edited) Ideally, you would have four fields: Min_cm, Max_cm, Min_in and Max_in, and they would all be Number fields. To do it with only two (Text) fields, as shown in your example, you could make the IN field auto-enter a calculated value (replacing existing value) = If ( Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName ) = GetFieldName ( Self ) ; Self ; Let ( [ v = Substitute ( CM ; "-" ; ¶ ) ; min = GetValue ( v ; 1 ) / 2.54 ; max = GetValue ( v ; 2 ) / 2.54 ] ; Round ( min ; 2 ) & "-" & Round ( max ; 2 ) ) ) and a similar formula for the CM field. No scripts are required for this. This assumes there will always be two values in the source field, separated by a hyphen - otherwise more work will be required to prevent the result being displayed as "21.65-0". Edited September 8, 2016 by comment 1
Recommended Posts
This topic is 2996 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now