SteveB Posted June 3, 2006 Posted June 3, 2006 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.
SteveB Posted June 5, 2006 Author Posted June 5, 2006 I was only interested in handling a hypenated first name, which this does. Steve
Genx Posted June 7, 2006 Posted June 7, 2006 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
SteveB Posted June 7, 2006 Author Posted June 7, 2006 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
Recommended Posts
This topic is 6742 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now