5 Replies Latest reply on Oct 22, 2009 3:10 PM by jwines

    Insert text at intervals

    jwines

      Title

      Insert text at intervals

      Post

      I'm running FM10 on Mac OS 10.5.8.

       

      I have a database, that I need to modify a text field, but I'm out of practice in my FileMaker scripting.

       

      I want to add a Line Feed every to the nearest word after 80 characters for a block of text. The Block of Text may be one sentence or paragraphs in length. A Line Feed doesn't have to be inserted, place holder text will do just as well, since the text will be exported and post processed and the place holder text can be delt with then.

       

       

      --Joshua.

        • 1. Re: Insert text at intervals
          philmodjunk
            

          This expression only looks for spaces to separate one "word" from another.

           

          Set Field [YourTable::YourTextField; Let ( [Fld=YourTable::YourTextField; Break = Position ( Fld ; " " ; 80 ; 1 )] ; Left ( Fld ; Break ) & "¶" & Right ( Fld; Length (Fld) - Break ) )

           

          • 2. Re: Insert text at intervals
            jwines
              

            The expression works for the first 80, not after. In the example I am using has 245 characters.

             

             

            --Joshua.

             

            • 3. Re: Insert text at intervals
              philmodjunk
                

              That's a detail not clear in your original post.

               

              You can loop the script, substituting a variable for the "80" parameter in the Position function:

               

              Set Variable [$NextBreak; value: 0]

              Loop

                Set Variable [$NextBreak; Position (YourTable::YourTextField; " " ; NextBreak$ + 80 ; 1] 

                Exit Loop if [$NextBreak = 0]

                Set Field [YourTable::YourTextField; Let ( Fld=YourTable::YourTextField; $NextBreak) ; Left ( Fld ; $NextBreak ) & "¶" & Right ( Fld; Length (Fld) - $NextBreak ) )

              End Loop

               

              You may have to tweak that a bit, but I think that'll do what you want.

              • 4. Re: Insert text at intervals
                jwines
                  

                Sorry for not being more clear. The text block will be of varing size, with out any user instered Paragraphs, just one long Paragraph.

                 

                I was entering your script, but I keep getting errors on the last Set Field command, just before the Left command.

                 

                I am now seeing just how much my FileMaker skills have atrophied! :)

                 

                 

                --Joshua.

                • 5. Re: Insert text at intervals
                  jwines
                    

                  Never mind, I made some changes, and now it works just as I want it to!

                   

                  Thanks again for all the great help!

                   

                   

                  --Joshua.