1 Reply Latest reply on Apr 5, 2012 6:13 AM by philmodjunk

    Text Manipulate

    HelderSantos

      Title

      Text Manipulate

      Post

      Hi, FM members

      How do i show the name abbreviated

      ex: if the name is "Mary Anna Paul Santos"

      the abbreviation should be "Mary A.P. Santos"

      how can i get this resolt?

      Thanks

        • 1. Re: Text Manipulate
          philmodjunk

          Is the text entered into a single field or do you have separate fields for first, middle and last names? (separate fields would simplify your calculation.)

          working from what you have...

          Set Variable [$MiddleCount ; value: WordCount ( YourTable::FullNameField ) - 2]
          Loop
             Set Variable [$K ; $K + 1]
             Exit Loop If [$K > $MiddleCount]
             Set Variable [$initials ; List ( $Initials ; Left ( MiddleWords ( YourTable::FullNameField ; $k + 1 ; 1 ) ; 1 ) &"." ) ]
          End Loop
          Set Field [YourTable::NameMiddleInitials ;
                         Trim ( LeftWords ( YourTable::FullNamefield ; 1 ) & " " & Substitute ( $Initials ; ¶ ; "" ) &
                         Case ($middleCount = 0 ; RightWords (YourTable::FullNamefield ; 1 ) ;
                                  $MiddleCount > 0 ; " " & RightWords (YourTable::FullNamefield ; 1 ) ) ) ]

          This could also be done with a recursive custom function if you have FileMaker Advanced. It should produce correct results for any number of middle names and also single word names.