We use gettok and substring: Here's what we go through to change our name to a lower case name and handle the Mc.. Mac... Hope the code comes through.
I_IDXA/I2 = IF AA003 CONTAINS '`' THEN
POSIT(AA003,32,'`',1,I_IDXA) ELSE 0;
AA003XYZ/A32 = IF I_IDXA EQ 0 THEN AA003 ELSE
OVRLAY(AA003,32,' ',1,I_IDXA,AA003XYZ);
TMP_NAME/A32 = GETTOK(AA003XYZ,32,2,',',32,TMP_NAME);
SFX_NAME/A5 = GETTOK(AA003XYZ,32,3,',',5,SFX_NAME);
FMN_NAME/A32 = LJUST(32,TMP_NAME,FMN_NAME);
FST_NAME/A32 = GETTOK(FMN_NAME,32,1,' ',32,FST_NAME);
-*MDL_NAME/A32 = GETTOK(FMN_NAME,32,2,' ',32,MDL_NAME);
LST_NAME/A32 = GETTOK(AA003,32,1,',',32,LST_NAME);
-*EXPNDNME/A72 = FMN_NAME || (' ' | LST_NAME | ' ') || SFX_NAME || '*';
EXPNDNME/A72 = FST_NAME || (' ' | LST_NAME | ' ') || SFX_NAME || '*';
CMPRSNME/A32 = GETTOK(EXPNDNME,66,1,'*',32,CMPRSNME);
SALX/A4 = LCWORD(4,AA008,SALX);
SAL/A5 = IF SALX EQ ' ' THEN ' ' ELSE SALX || '.';
FUL_NAME/A32 = LJUST(32,CMPRSNME,FUL_NAME);
FULXNAMA/A32 = LCWORD(32,FUL_NAME,FULXNAMA);
I_IDX/I2 = IF FULXNAMA CONTAINS ' Mc' THEN
POSIT(FULXNAMA,32,' Mc',3,I_IDX) ELSE 0;
I_IDX2/I2 = I_IDX + 3;
I_IDX3/I2 = I_IDX + 4;
GETCHAR/A1 = IF I_IDX EQ 0 THEN ' ' ELSE
SUBSTR (32,FULXNAMA,I_IDX2,I_IDX3,1,GETCHAR);
NEWCHAR/A1 = UPCASE(1,GETCHAR,NEWCHAR);
FULXNAMT/A32 = IF GETCHAR EQ ' ' THEN FULXNAMA ELSE
OVRLAY(FULXNAMA,32,NEWCHAR,1,I_IDX2,FULXNAMT);
I_IDXA/I2 = IF FULXNAMT CONTAINS ' Mac' THEN
POSIT(FULXNAMT,32,' Mac',4,I_IDX) ELSE 0;
I_IDXB/I2 = I_IDXA + 4;
I_IDXC/I2 = I_IDXA + 5;
GETCHARA/A1 = IF I_IDXA EQ 0 THEN ' ' ELSE
SUBSTR (32,FULXNAMT,I_IDXB,I_IDXC,1,GETCHARA);
NEWCHARA/A1 = UPCASE(1,GETCHARA,NEWCHARA);
FULXNAMZ/A32 = IF GETCHARA EQ ' ' THEN FULXNAMT ELSE
OVRLAY(FULXNAMT,32,NEWCHARA,1,I_IDXB,FULXNAMZ);
I_IDX4/I2 = IF FULXNAMZ CONTAINS ' Iii' THEN
POSIT(FULXNAMZ,32,' Iii',4,I_IDX4) ELSE 0;
I_IDX5/I2 = I_IDX4 + 1;
GETCHAR6/A3 = IF I_IDX4 EQ 0 THEN ' ' ELSE 'III';
FULXNAMW/A32 = IF GETCHAR6 EQ ' ' THEN FULXNAMZ ELSE
OVRLAY(FULXNAMZ,32,GETCHAR6,3,I_IDX5,FULXNAMW);
I_IDX6/I2 = IF FULXNAMW CONTAINS ' Ii' THEN
POSIT(FULXNAMW,32,' Ii',3,I_IDX6) ELSE 0;
I_IDX7/I2 = I_IDX6 + 1;
GETCHAR7/A3 = IF I_IDX6 EQ 0 THEN ' ' ELSE 'II';
FULXNAME/A40 = IF GETCHAR7 EQ ' ' THEN FULXNAMW ELSE
OVRLAY(FULXNAMW,32,GETCHAR7,2,I_IDX7,FULXNAME);
FRSTNAMX/A32 = LCWORD(32,FST_NAME,FRSTNAMX);
NAME_LEN/I2 = ARGLEN(32,FRSTNAMX,NAME_LEN);
PER_POS/I2 = IF NAME_LEN LE 2 THEN POSIT(FRSTNAMX,32,'.',1,PER_POS)
ELSE 0;
PERNAM/A34 = '. ' | LST_NAME;
FRSTNAMT/A38 = IF NAME_LEN GT 2 THEN FRSTNAMX
ELSE IF (PER_POS EQ 0) AND (NAME_LEN EQ 2) THEN FRSTNAMX ELSE
IF SALX EQ ' ' THEN 'M' || PERNAM ELSE
SALX || PERNAM;
FRSTNAME/A40 = LCWORD (38,FRSTNAMT,FRSTNAME);
Leah