* * Assumes pattern of "Last, First, Middle" - assumes comma is delimiter and there are * no more than three items (otherwise last item contains remainder which may contain * commas). * * Really bad form here -- as it is a UDF that doesn't return a meaningful value, and * modifies values of some of its parameters. * * Somewhat "brute force" method -- probably not the best way to handle this. STORE "" TO cLN,cFN,cMN =ParseName( "Smith, John, D Jr", @cLN, @cFN, @cMN ) ? "Last: ",m.cLN ? "First: ",m.cFN ? "Middle: ",m.cMN PROCEDURE ParseName ( cFullName, cLast, cFirst, cMiddle ) LOCAL nLoc nLoc = AT(",",m.cFullName) cFirst = "" cMiddle = "" IF m.nLoc==0 THEN cLast = ALLTRIM(m.cFullName) ELSE cLast = ALLTRIM(SUBSTR(m.cFullName,1,m.nLoc-1)) cFirst = ALLTRIM(SUBSTR(m.cFullName,m.nLoc+1) nLoc = AT(",",m.cFirst) IF m.nLoc<>0 THEN cMiddle = ALLTRIM(m.cFirst,m.nLoc+1) cFirst = ALLTRIM(m.cFirst,1,m.nLoc-1) ENDIF ENDIF ENDPROC