14 Replies Latest reply on Apr 18, 2017 6:40 PM by user19752

    get FUNCTION



      get FUNCTION


           I'm looking for a  (get FUNCTION) that tells me if all the content of the field is displayed on the screen in a field that’s display on the screen (in form view). Is there  a standard function in Filemaker that I’ll can use?


           The idea of this function is to use is in a Conditional formatting solution.

           If not al the content is displayed fill the field whit a collar.


           Or is there a other why to get this information?

        • 1. Re: get FUNCTION

               There is no such get function and such would be really useful: http://www.filemaker.com/company/contact/feature_request.html

               You can count the number of characters using the Length function, but this is only a crude indicator as to whether the text will fit the dimensions of the field object as iiiiiiiiii and WWWWWWWWWW are both 10 characters in length.

               There is a scripted way to adjust the text to fit the field and it is one of the most God Awful Kludges used in FileMaker systems:

               Create a separate layout with this same field where the width of the field and the text style settings are identical.

               Increase the height of the field so that more than one row of text will be visible in it.

               Use the inspector to give this field an object name.

               Use the inspector to set this field to "slide up".

               When you enter preview mode on this layout, the field will reduce in height to fit the text in the field.

               Now create a script that switches to this layout, enters preview mode and uses getLayoutObjectAttribute to check the height of the previewed field. If the text fits in a single row in this field, this function will then return a smaller height than if it "wraps" to more than one line.

               This script can be set to loop using the TextSize function to gradually reduce the size of the text until it fits the field.

               This method cannot be used in FileMaker GO on an iOS device.

               PS. A simpler device that I figured out to help out a client creating Labels for his greenhouse plants, is to set up a pair of buttons, one for increasing the text size and one for decreasing. This client just clicks the appropriate button repeatedly until he gets the best possible "fit" of text to field.

          • 2. Re: get FUNCTION

            I know this is 2 years old, but I am trying to use this process to determine if a field has been truncated or not. The problem is that GetLayoutObjectAttribute does not work in Preview mode and what it returns in Browse mode is not useful.


            Any ideas?


            I am using FM Pro Advanced 13.0v9, Mac OS.

            • 3. Re: get FUNCTION
              The problem is that GetLayoutObjectAttribute does not work in Preview mode

              On the contrary, this function does work in preview mode and this is a requirement for the above very clumsy work around to actually work.

              • 4. Re: get FUNCTION

                Well, it is not working for me. In preview mode, my variable does not evaluate but it does in browse mode. (Using debugger and data view)


                Go to Layout [  ; “aaaa” ]

                Enter Preview Mode []

                Set Variable


                I have tried different attributes and get no values, but if I disable Enter Preview Mode, the variable gets a value.


                Your sequence was to set the field before switching layouts, but I can’t see that that would make any difference, does it?


                Thank you and appreciate any advice you may have.


                Donald Brown

                • 5. Re: get FUNCTION

                  Once more, FYI -


                  the following attributes work in Preview mode, the others do not:








                  None of the position attributes work in preview mode (they work in browse mode) -

                  bounds, left, right, top, bottom, width, height, startPoint, endPoint

                  • 6. Re: get FUNCTION

                    I don't know if my original post was in error--if so no one caught it over the years, or if there's been a behavior change but you are correct that this doesn't work in Preview mode in FMA 13.


                    The following method, however, does work and works in browse mode.


                    Go to field [Select ; YourTable::field ]

                    Pause/Resume [0 seconds]

                    If [GetLayoutAttribute ( "YourField'sObjectNameHere" ; "Height" ) > SpecifyFieldHeightInPointsHere ]
                      #Does not fit



                    End If


                    First time around, it worked only in the debugger so I used an old trick to include to pause zero seconds and the script then worked. It's measuring how far the field "pops out" when you drop the cursor into the field to see if the text fits. You can do this test in a window hidden off the edge of the monitor to hide all the layout updates if you want.


                    The demo file is misnamed as it turns out that I'm not using the "sliding fields" option in the final form of this technique.

                    1 of 1 people found this helpful
                    • 7. Re: get FUNCTION

                      Thank you for your help. Very much appreciated. (Seems to me FM should get that function working on all parameters. The app certainly knows where everything is and there should be a way to retrieve that information for us through this function. )


                      Will give your method a try.

                      • 8. Re: get FUNCTION

                        I tried that and it doesn’t work for me in Preview Mode. I tried it with ‘Enter Preview Mode’ at beginning (before Go to field), between Go to field and Pause, and immediately after Pause. None worked.


                        The key is Preview mode with a sliding object so I get the height value which lets me know when the text has wrapped. Browse mode is not useful since I will always get the height set in layout mode.


                        So I will think about this overnight then probably look for some other approach.


                        Thanks for you help and giving some thought to this.

                        • 9. Re: get FUNCTION

                          My example that I just posted does NOT use preview mode but DOES check for "Fit" in a given field. It works--at least in FMP advanced 15--the version that I used to create and test the example.


                          So I do not see why you tried to do it in preview mode as the method that I've just posted runs in BROWSE mode.

                          • 10. Re: get FUNCTION

                            I apologize for my failure to read your email more carefully. I had been focused on the preview + sliding feature to test any changes, and it didn’t register with me that I should have reduced the layout field height to a single line (or whatever I wanted to test for) which I hadn’t done. (End of day - not much useful gets accomplished). I also wasn’t sure, until I reread it this morning, what you meant by “pop out”, but when I tried it this morning and saw it “pop” out, it registered what you were saying.


                            Also, since I had been focused on preview mode and sliding, I misinterpreted your comment “the following method, however, does work and works in browse mode.” I thought you were telling me it would work in both modes.


                            So anyway, all is well and you have been a great help. Thank you for your help - I am very grateful.


                            (Instead of a constant field height to test against, one could use the FieldBounds function to calculate what has been set on the layout, so if layout field gets changed, the test will still work.)

                            • 11. Re: get FUNCTION

                              I like that modification as it makes a more generalized implementation possible.

                              • 12. Re: get FUNCTION

                                … and if they gave us access to the final word count it wrapped at, we could figure out what % is visible and how much reduction would have to be done to capture it all in the allotted space. Wrapping implies algorithms that determine what word to break at.


                                Since we don’t have access to that, if someone had a small database like me, or few occasions for wrapping so it wouldn’t consume a lot of calc time, could write a loop pasting one word less each time until it fit in the allotted space which gives us what we are looking for.

                                • 13. Re: get FUNCTION

                                  Part of what complicates this for FileMaker and will also complicate this particular Kludge is that the font metrics for each platform are different. So determining that this text "fits" on a Mac for example does not guarantee fit in either Windows or iOS. You can get reasonable results for just Mac and Windows if you do the test on a windows system since the Macs require slightly less space to display the same text, but iOS (FileMaker Go) will be different yet.

                                  • 14. Re: get FUNCTION

                                    The function is working in preview mode, but can't calculate in data viewer since there are many objects they have same object name and different value. (Browse mode may be using current record)

                                    You can see that it works when used in conditional formatting calculation.

                                    If you want to get the result in variable, you'd need array for each record.


                                    $$h[Get(RecordNumber)] = GetLayoutObjectAttribute("textbox1";"height") ;

                                    $$h[Get(RecordNumber)] = 61 //height defined in layout mode