13 Replies Latest reply on Dec 19, 2013 3:50 PM by philmodjunk

    Button to convert Dimensions from Inches to meters

    AbdoulBaldé

      Title

      Button to convert Dimensions from Inches to meters

      Post

           Hi, 

           On my Layout I am displaying rooms dimensions through a portal. In this portal I have the following fields :

           Room_ID ; Room_Name ; Room_Length ; Room_Height ; Room_Surface . As I have both dimension type (meters in inches ) in my database, I could simply import all records and rename the fields to Room_Length _1 (for meters) and add a field Room_Length_2 

           I am trying to simplify the database and avoid having to import the data in both meters and inches. I am trying to setup a button to convert all the data from meters to inches. I know I have to add a calculation field and select the field to be converted and multiply by the conversion factor.  

            

           Can I do it with many fields at the same could you please advise on the script?

           Thanks. 

            

            

        • 1. Re: Button to convert Dimensions from Inches to meters
          philmodjunk

               Adding a calculation field does not involve scripting and the change will apply automatically to all records in your table. Just make sure that this is a field of type calculation and not a field of type number with an auto-enter calculation. Adding/changing an auto-enter calculation does not automatically produce an updated value in existing records.

          • 2. Re: Button to convert Dimensions from Inches to meters
            AbdoulBaldé

                 Ok Thanks. 

                 Please see below the fields in my Table. I am trying to avoid having to add a field (AND RECORS) for Room_Width_Meters/ Room_Length_Meters... with the same setup as the Room_Surface_SquareMeters. Is it possible to have a field type or use a script to convert all the Fields (Room_Width_Inches, Room_Length_Inches, Room_Height_Inches, Room_Surface_SquareFoot) into the equivalent value in the Inches? 

                  

                 Thanks. 

            • 3. Re: Button to convert Dimensions from Inches to meters
              philmodjunk

                   The room dimension fields should be number, not text. Replace Field Contents can be used to convert all values from inches into equivalent metric values, there's a calculation option that you can use. Then you just need to rename your fields after converting the values.

                   But if you have used fractional notation for your dimensions in inches, your calculations for the conversion could be tricky to set up--especially if there are variations in how the dimensions were entered.

              • 4. Re: Button to convert Dimensions from Inches to meters
                AbdoulBaldé

                     Thanks. I will have to change my records so that all records have the same format with no fractions. I am wondering can I still use the " sign for inches with Number Fields? Also. If I undrestand correctly I will have to set up a button with the following script:

                Replace Field Contents [No dialog; Rooms Tables::Room_Length_Inches; Rooms Table::Room_Length_Inches*.328084] ?

                     Regarding renaming the field to Room_Length_Inches to Room_Length_Meters I havent been able to find a script that could perform that. Could you please help?

                      

                     I was thinking that I could simply use Fields like Room_Length and then use the 

                     Replace Field Contents by the value in meters if I have both metrics in my table ? This way I would not even have to use calculations right?

                      

                     Thanks. 

                      

                • 5. Re: Button to convert Dimensions from Inches to meters
                  philmodjunk

                       I'm a bit puzzled. If you are converting the measurements to metric, why would you want to show the " symbol for inches? You can put the units on your layout as layout text or you can get sneaky and specify a currency data format, but edit the currency symbol to be your measurement units and set them to show to the right instead of the left of the number.

                       

                            Also. If I undrestand correctly I will have to set up a button with the following script: Replace Field Contents [No dialog; Rooms Tables::Room_Length_Inches; Rooms Table::Room_Length_Inches*.328084]

                       Or if this is a one time update, you can just select Replace Field Contents from the Records menu after putting your cursor into the field. wink

                       In both cases, you'll want to do a show all records first as this modifies the specified field for every record in your found set. (And you  should save a copy of your file first before trying to use replace field contents for the first time. If things go wrong, you can't undo this change.)

                  • 6. Re: Button to convert Dimensions from Inches to meters
                    AbdoulBaldé

                         Thanks, I will keep this one for later as it appears to be risky. 

                    • 7. Re: Button to convert Dimensions from Inches to meters
                      philmodjunk

                           No more risky than a looping script that changes the records one record at a time. And it's easy to protect yourself by making a back up copy before you try it.

                           BTW, don't see how a conversion factor of .3280894 is going to convert inches into meters. Perhaps your values are really in feet? (but even that doesn't appear quite right...)

                           To convert inches into meters, you'd multiply by 2.54cm/in * 1 M / 1000 cm which would be   0.00254. (years ago, I used to teach this stuff. wink)

                      • 8. Re: Button to convert Dimensions from Inches to meters
                        AbdoulBaldé

                             Thanks. I am so confused and confusing. I did indeed used inches in my whole post but I meant feet.  thanks for the tip, you sent back to school :)  (I can tell that you were teaching this before by the way it is explain).

                             To convert to meters to feet , I have to use the conversion factor 3.280894. 

                              

                        Let me explain my issue again as I now have a better understanding:

                             1- On my Layout, I am using a portal to display rooms and their dimensions (in both meters & feet) by Level. 

                             => Layout is based on Floor level Table which I linked to Rooms & Dimensions (using the floor level Id in both Tables : one is _kp and the other is _kf

                             2- When clicking a Floor Level button , I am able to see the related rooms and their dimensions

                             3- Since I plan to use it in FileMaker Go, I have space limitation

                             4- I would like to display only room dimensions in meters in my portal with a button to convert the fields (Room_Width / Room_Length / Room_Height)

                             5- If I use Replace field content , I can specify the field to be replaced as well as the field that will replace the current fields. 

                             ==> If I use this , I don't have to use calculations or formula to convert right? This is ok since I have both values in meters and feet already inmported in my Table. 

                             Also, Since the only the value of the fields will change, I need generic Labels such Room Width (not specifying meters or feet0 

                             ==> I was thinking I could use a new field _selectedmetric to let the user know if he is in meters or feet. 

                             Do you think this is the right way to do it? 

                             Thanks,

                              

                        • 9. Re: Button to convert Dimensions from Inches to meters
                          philmodjunk

                               I'm a bit confused too by your last post. wink

                               

                                    On my Layout, I am using a portal to display rooms and their dimensions (in both meters & feet) by Level.

                               Does that mean that you have two sets of dimensions fields, one set for metric and one set for imperial measurements?

                               

                                    I would like to display only room dimensions in meters in my portal

                               If you have a set of fields for each measurement system, why not just use only the metric fields in this portal? Why do you need to do any scripted alteration of your measurements here?

                               This really does not look like a place to use Replace Field contents. Simply having two sets of fields and only showing one would be far simpler. Calculation fields or auto-entered calculations can take the measurements entered using one system and can compute the converted units for the other.

                          • 10. Re: Button to convert Dimensions from Inches to meters
                            TSGal

                                 All:

                                 Perhaps I'm missing something, but 1 meter equals 39.3701 inches.  The factor 3.280894 is number of feet in 1 meter.

                                 TSGal
                                 FileMaker, Inc.

                            • 11. Re: Button to convert Dimensions from Inches to meters
                              philmodjunk

                                   Which is why Abdoul Baldé posted:

                                   

                                        To convert to meters to feet , I have to use the conversion factor 3.280894.

                                   He's actually working with feet, not inches here.

                              • 12. Re: Button to convert Dimensions from Inches to meters
                                TSGal

                                     PhilModJunk:

                                     My fault.  The title of the thread threw me as I followed it through the first few posts with inches.  I'll stay out of the way now.  :-)

                                     TSGal
                                     FileMaker, Inc.