June 3, 200619 yr Name & Parameters: [color:red][big] GetFirstName ( FullName ) [/big] Description: Return a person's first name. Skips over titles, will also return a hyphenated first name, or a second name where the person uses his first name initial. Sample Input: 1) Mrs. Ann-Marie Smith 2) Dr. J. Harry Morton 3) John Doe Results: 1) Ann-Marie 2) Harry 3) John Recursive: no Formula: /* CF: Returns A Contact's First Name from a Full Name CF: GetFirstName FullName */ Let ( [ name= Substitute ( FullName; "-" ; "00" ); // Needed because FM treats lots of characters as separators fw= LeftWords ( name ; 1 ); title= Case( fw= "Mr" or fw= "Mrs" or fw= "Ms" or fw= "Miss" or fw= "Prof" or fw= "Dr"; fw; "" ); // Trap title if it exists start= Case( WordCount(title) ≤ 0; 1; 2); // Skip title if necessary start= Case( Length( MiddleWords ( name ; start ; 1 )) ≤ 1; start+1; start) // Move over 1 if initial: returns 'Thomas' if name is 'J. Thomas Smith' ]; Substitute( MiddleWords ( name ; start ; 1 ); "00"; "-") // Replace with dash ) Required Functions: Author(s): Steveinvegas Date: 06/03/06 Credits: Disclaimer: FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.
June 5, 200619 yr Author I was only interested in handling a hypenated first name, which this does. Steve
June 7, 200619 yr I simply use four fields for a name - First Title, Second First, Third Middle, Fourth Last. It reduces confusion, though this function does look like it might have some use to me anyway in terms of reparsing into the database. Cheers, ~Genx
June 7, 200619 yr Author Yeh, but...it takes more screen real estate and users are more likely to make mistakes by typing multiple words into 1 field. I usually (against convention) keep the full name in one field. I had a script to split things out when I needed to, but these functions make things more convenient. Steve
Create an account or sign in to comment