1 2 Previous Next 17 Replies Latest reply on Jul 27, 2017 10:32 AM by f.i.sciences

    Count lines in a textbox

    ianselmo

      I need to find a way to count the lines in a text box. I want to validate that the maximum lines allowed is not exceed because I transfer the information to a PDF files and i need to validate the maximum or else i cannot see all the information. The number of caracters is not good for me because If they press 'Enter' to add lines it doesn't work

        • 1. Re: Count lines in a textbox
          mikebeargie

          you can't count lines, as the length of a line can change depending on things like zoom, width of the line, etc...

           

          Why don't you just patterncount for the linebreaks?

           

          Let([

             t = table::field;     //your text field

             tlen = length(t);    //overall character length of text string

             tbr = patterncount ( t ; ¶ );    //count the line breaks

             linelen = 15    //the character length of each "line"

          ];

             round (tlen/linelen; 0) + tbr     //round the lines based on characters, add the number of line breaks.

          )

           

          Adjusting the above around could get you close.

          1 of 1 people found this helpful
          • 2. Re: Count lines in a textbox
            StephenWonfor

            Another thing that might help is the use of a mono-spaced (fixed width) font - the venerable Courier for example.  You could enforce this with an auto-enter calc using TextFont ( text ; fontName {; fontScript} ).  The fixed-width of the font would allow you to manage field contents using Mike's logic.

             

            Stephen

             

            "Courier 12 is the Type-O blood of fonts - works just as good for a 'N.Y. Times' op-ed as a screenplay or a short story." ~Andrew Vachss

            • 3. Re: Count lines in a textbox
              rgordon

              You have entered this discussion  twice.  Your question was addressed in the other discussion. Please delete this discussion.

              • 4. Re: Count lines in a textbox
                Benjamin Fehr
                = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =                                       the original post can be found here:   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   https://community.filemaker.com/thread/80647
                • 5. Re: Count lines in a textbox
                  lindseym

                  I ended up doing a pattern count based on @Mike Beargie.

                   

                  Because my data has a carriage return represented by a semi colon, which is substituted in FMP with a carriage return... I was able to do this equation and it works out great. I had to add 1 because the last line never has a carriage return.

                   

                  PatternCount ( Longest Message DWG ; "¶" )  +  1

                   

                  Thanks for the idea!

                  • 6. Re: Count lines in a textbox
                    philmodjunk

                    Just for future reference, it IS possible to count the number of lines of text in a field created due to textwrap as well as returns, but it's a weird one done by putting the cursor into the field while in Browse mode and using GetLayoutObjectAttribute to measure the height of the field.

                     

                    Requires a one row high field (or a field of the same width and format of one row height).

                    Doesn't work if field has a scroll bar.

                    Doesn't work in Go or on the Web.

                    • 7. Re: Count lines in a textbox
                      rgordon

                      This technique does work in FileMaker Go but here is something interesting (scary?) that I found.  I tested this in FileMaker Go 15 and it didn't work.  I know previously this has worked in FMGO so I then tested in FMGO 14 and 16.  Worked with no problem.  I restarted the iPad and now the technique works in FMGO 14, 15, and 16.  Moral of the story is restart iPads frequently to make sure FMGO works properly.

                      • 8. Re: Count lines in a textbox
                        lindseym

                        "Restart Frequently"

                         

                        I swear overtime my computer is being weird.... that's the first thing I am told to do... and 99% of the time the problem is solved.

                         

                        You think I would learn.

                        • 9. Re: Count lines in a textbox
                          beverly

                          LOL! true. Another common Tech support answer:

                          "Step away from the keyboard!"

                          Beverly

                          • 10. Re: Count lines in a textbox
                            rgordon

                            When troubleshooting a misbehaving script in FMGO, I find dropping a strategical located crap (Commit, Refresh, And/or Pause) on the script solves a majority of the problems.  

                             

                            Roy Gordon

                            PSFE

                            Sent from my iPhone

                            • 11. Re: Count lines in a textbox
                              Menno

                              I would use the function:

                              GetLayoutObjectAttribute ( "YourTextField" ; "height" )

                              Put the field you'd like to check on the layout with the maximum proportions and make sure the field doesn't have a scrollbar. Give the field an objectname, for example "YourTextField".

                               

                              If the field is not activated c.q. the cursor is not in the field, this function returns the height of the field on the layout. If you use

                              Go to Object ["YourTextField"]

                              to activate the field, then this function stil returns the height, but if there is too much text in the field, it will be higher than it is when the field is inactive.

                              2 of 2 people found this helpful
                              • 12. Re: Count lines in a textbox
                                f.i.sciences

                                This IS WOW!

                                 

                                Do you know how we calculate the height of a line (formula)?

                                If it's 0.8 interline?

                                 

                                For exemple, my field is 22 height.

                                When I select it with only 1 line, it grow to 30.

                                If I do 2 lines it grow 39, 3 lines it's 52.

                                 

                                Thank you.

                                • 13. Re: Count lines in a textbox
                                  beverly

                                  What are the padding settings for the field? Padding (top & bottom) will not change per line, but remains for the full box.

                                  Do your test after changing (Inspector, Appearance tab) to 0 Top and 0 Bottom. Does it help in any way?

                                  Beverly

                                  • 14. Re: Count lines in a textbox
                                    f.i.sciences

                                    Was already set to 0 top/bottom and left/right.

                                    1 2 Previous Next