% % stack: [ [|]token . . . ] count % % this is a name of the customer % seek out the next begin of line or end of words % dup index *splitpre { % % this was a gender pronoun % "loopc" log)( dup + -1 roll !Cust.Pronoun - pos( { "loopd" log)( *splitnam } if } { % % this is the start of the name, find the next bol % dup { dup unwhole ? "loope" log)( dup + index "|" atleft ? - } loop % % stack: [ [|]token . . . ] count idx % second from "words" log)( < |0 % no name |1 % 1 word % % use as middle initials/nickname % dup + -1 roll "|" remove !Cust.Middle - |2 % 2 words % % first and last % dup + -1 roll "|" remove !Cust.First - dup + -1 roll "|" remove !Cust.Last - |3 % 3 words % % first last and middle % dup + -1 roll "|" remove !Cust.First - dup + -1 roll "|" remove !Cust.Middle - dup + -1 roll "|" remove !Cust.Last - > not { % % more than 3 words % dup + -1 roll "|" remove !Cust.First - dup + -1 roll "|" remove !Cust.Middle - dup + -1 roll "|" remove !Cust.Last - { dup index "|" atleft { % % end of word chain % true } { dup + -1 roll "|" remove _Cust.Last &" " ^ !Cust.Last - false } ifelse ? } loop } if "loopf" log)( } ifelse % % stack: [ [|]token . . . ] count idx idx-word % % see if the following tokens on the same line are properly % formatted to be a name % % possible word sequences are: % pull out mr mr. mrs mrs. ms ms. dr., note gender % seek first comma, following words inserted before prior words % clean out any other commas % first (or initials or nickname) % ifirst.last (missing space after period of first initial) % ifirst.ilast (two letter name abbreviation, missing last period) % ifirst.ilast. (two letter name abbreviation) % first imiddle.last (missing space after mid intitial period) % ifirst.middle last (missing space after first intitial period) % ifirst. middle last % ifirst.imiddle.last (missing space after mid intitial period) % ifirst.imiddle. last % ifirst. imiddle. last % ifirst. imiddle. ilast (missing last intitial period) % first last % first. last (first name word may be other type of prefix 3 chars max) % first imiddle. % first middle last % first. middle last % pref. first last % pref. first middle last % (first name word may be other type of prefix 3 chars max) % first middle. last % suffix may be at end like jr jr. sr sr. %