June 3, 200619 yr Name & Parameters: [color:red][big] GetLastName ( FullName ) [/big] Description: Returns a person's Last Name. Ignores suffixes such as 'Jr', 'Sr', 'III'. Also returns a hyphenated Last Name Sample Input: 1) Prof. Henry James 2) John Smith-Peters 3) Henry Higgins PhD Results: 1) James 2) Smith-Peters 3) Higgins Recursive: no Formula: /* CF: Returns A Contact's Last Name from a Full Name CF: GetLastName FullName */ Let ( [ name= Substitute ( FullName; "-" ; "00" ); // Needed because FM treats lots of characters as separators nword= WordCount( name ); rw= RightWords ( name ; 1 ); suffix = Case( rw= "SR" or rw= "JR" or rw= "II" or rw= "III" or rw= "IV" or rw= "MD" or rw= "DR" or rw= "PhD" or rw= "Esq"; rw;"") // Trap suffix if it exists ]; Substitute( Case( WordCount( suffix) > 0; MiddleWords ( name ; nword -1; 1 ); MiddleWords( name; nword; 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.
Create an account or sign in to comment