5 Replies Latest reply on Jul 19, 2015 7:17 AM by philmodjunk

    Managing Layouts and Tables

    MattStephens

      Title

      Managing Layouts and Tables

      Post

      I am trying to subtract values (end odometer - start odometer) from two separate layouts in order to calculate total km driven.

      I tried separate tables but couldn't get the calculation to return the correct value and am not sure whether I need to refer to a row number or if there is more I need to do, like develop a relationship...

      I now have one table with two layouts (see screenshot) but each layout entry appears on alternate rows of the table, again, making the calculations difficult. I also want to calculate the total time (end time - start time) so just subtracting the totals at the bottom of the table wont do..!

      Can I make each layout enter data onto the same row of the table?

      Thanks,

      Matt

      Screen_Shot_2015-07-19_at_12.35.53_am.png

        • 1. Re: Managing Layouts and Tables
          philmodjunk

          That doesn't really make any sense. You don't/can't subtract values from layouts. Layouts don't store data. The table on which the layout is based stores the data. Note that your data is being stored in the same table no matter which layout is used to enter the data.

          I don't see a need at this moment for more than one layout and one table. But I think you should back up a few steps and describe what you want to do.

          I suspect that we can set up an auto-enter field option to copy the previous odometer reading into the new record so that you now have previous and current readings in the same record such that you can now subtract to find the distance traveled.

          • 2. Re: Managing Layouts and Tables
            MattStephens

            Thanks Phil,

            I was thinking about how I could replicate the field in the table so that would be great.

            I need two layouts because at the start of the drive, I enter some details, then at the end of the drive, I enter some additional details. And I would prefer to do this on two different screens (due to iphone size sceen) My problem is that each layout enters data into alternative rows. My goal is to create a summary page that gives values for total km travelled for each journey and total time for each journey. I hope this makes sense.

            Any advice on auto-enter fields would be great. 

            Cheers,

            Matt 

            • 3. Re: Managing Layouts and Tables
              philmodjunk

              Letting people know that you are working on an FM GO solution and using an iPhone is not good information to leave out of your post--especially when you post to the FM PRO forum instead of the FM GO forum section.

              The fact that you are using two different layouts does not mean that you can't use both layouts to edit the same record in the same table. I will call your first layout "departure" and your second "arrival". What you can do is create a new record on departure and then find and update that record on Arrival. Depending on your underlying data model, that may simply be a case of not doing anything but switching to the departure layout.

              The other option is to set up two number fields in your table: CurrentOdom, PrevOdom. Give PrevOdom this auto-enter calculation: Let ( R = Get ( RecordNumber ) ; If ( R > 1 ; GetNthRecord ( CurrentOdom ; R-1 ) ). This will copy the previous odometer reading into PrevOdom and then a third field can use CurrentOdom - PrevOdom to calculate the elapsed distance.

              • 4. Re: Managing Layouts and Tables
                MattStephens

                Thanks Phil,

                I got it to work but with a couple of corrections: CurrentOdom should be PrevOdom and a third closing bracket was needed:

                Let ( R = Get ( RecordNumber ) ; If ( R > 1 ; GetNthRecord ( PrevOdom ; R-1 ) ) )

                I am actually working in FM PRO, I just set up an iphone size display (layout) to model how it would look when displayed on a phone. The task I am working on is a school project and not for commercial use.

                If you are willing, my second issue is to do with making a time calculation. When I try the same function (subtracting two time records, I get the wrong value: for example 11:35:12am - 11:32:12am does not = 3mins. 

                Can you suggest the best way to get a value for the amount of time that occurs between two button presses..?

                Cheers,

                Matt

                • 5. Re: Managing Layouts and Tables
                  philmodjunk

                  No, this expression should copy from the current odometer reading from the previous record, not the previous odometer reading or you will skip an odometer reading.

                  Of course you are working in FM Pro as you have to develop in Pro (or better in Advanced) before you can use it in FM GO on the iPhone. But it still helps others to help you when you tell them that this is what you are doing as some solutions either don't work or aren't practical in GO even though they are in Pro.

                  When you subtract two time fields, the difference is expressed in seconds. You have to divide by 60 to get a value in minutes. Or you can specify a Time result type and then you can get elapsed time in hours:Minutes:Seconds. (Make sure that your Time fields are fields of type time and not text.)

                  Note that time and timestamp fields store their values as a number of seconds. Time fields store the number of seconds from midnight to the time shown in the field. TimeStamp fields store the number of seconds from Midnight 1/1/0001 to the date, time shown in the field.