Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parse Name to Separate Parts
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01219298
Message ID:
01219335
Views:
14
BTW, the Anderson IV, HENRY - do you need to parse it as two different names, e.g. Anderson Iv and Anderson Henry assuming husband and wife? (Is Iv a woman's name?)

>The name are in the format, unfortunately, I can't utilize outlook, since not everyone of my clients has outlook (lots of lotus notes users).
>
>lastname, firstname mi
>or
>lastname firstname mi
>
>Sample
>
>KEAN, CHARLES
>ANDERSON IV, HENRY
>JACOBS THERESA R
>COVINGTON ANGELITA M
>
>
>Here is what I have so far...it's not very elegant. If you have a shareable routine, I'd appreciate it. Thanks
>
>PARAMETERS tcName
>IF PCOUNT()=0
>	lcRefDocName=["ANDERSON IV, HENRY"]
>ELSE
>	lcRefDocName=tcName
>ENDIF
>LOCAL lcReturn,lcLast,lcFirst,mi,lnLen
>
>lcRefDocName=ALLTRIM(lcRefDocName)
>lnlen=LEN(lcRefDocName)
>***********************************************
>* they've put a comma at the end of some of
>* the name, we need to remove that
>***********************************************
>IF RIGHT(lcRefDocName,1)=[,]
>	lcRefDocName=SUBSTR(lcRefDocName,1,lnLen-1)
>ENDIF
>***********************************************
>* Determine the comma for where the last name
>* ends
>***********************************************
>lnComma=ATC(',',lcRefDocName)
>***********************************************
>* If there is a comma now, it should represent
>* the split betwen the lastname and firstname
>************************************************
>IF lnComma>0
>	lcLastName=SUBSTR(lcRefDocName,1,lnComma-1)
>	***************************************************
>	* Determine if there is a space after the comma
>	***************************************************
>	lcCharAfterComma=SUBSTR(lcRefDocName,lnComma+1,1)
>	IF lcCharAfterComma=" "
>		lnSecondSpace=ATC(' ',lcRefDocName,2)
>	ELSE
>		lnSecondSpace=ATC(' ',lcRefDocName,1)
>	ENDIF
>	
>	IF lnSecondSpace=0
>		lnSecondSpace=15
>	ENDIF
>	lnFirstStartsAt=lnComma+1
>	lnFirstEndsAt  =lnSecondSpace
>	lnDis=lnFirstEndsAt-lnFirstStartsAt
>	
>	lcFirstName=SUBSTR(lcRefDocName,lnFirstStartsAt,lnDis)
>	lcFirstName=ALLTRIM(lcFirstName)
>	
>	lcMi=SUBSTR(lcRefDocName,lnSecondSpace+1,5)
>	lcMI=ALLTRIM(lcMI)
>	lcMI=SUBSTR(lcMI,1,1)
>	
>	lcReturn=[|]+lcLastName+[|]+lcFirstName+[|]+lcMI+[|]
>ELSE
>	IF ATC(' ',lcRefDocName,1)>0
>		lnFirstEndsAt=ATC(' ',lcRefDocName,1)
>		* there are at least two words
>		lcLastName=SUBSTR(lcRefDocName,1,ATC(' ',lcRefDocName,1))
>		lnSecondSpaceAt=ATC(' ',lcRefDocName,2)
>		IF lnSecondSpaceAt>0
>			lndiff=lnSecondSpaceAt-lnFirstEndsAt
>			lcFirstName=SUBSTR(lcRefDocName,ATC(' ',lcRefDocName,1)+1,lnDiff)
>			** ToDo - Figure out if there is a midddle
>			lcMi=[]
>		ELSE
>			lcFirstname=[]
>			lcMI=[]
>		ENDIF
>		lcReturn=[|]+lcLastName+[|]+lcFirstName+[|]+lcMI+[|]
>	ELSE
>		lcFirstname=[]
>		lcReturn=[|]+lcRefDocname+[|]+lcFirstName+[|]+[ |]
>	ENDIF
>ENDIF
>RETURN (lcReturn)
>
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform