Subj : Final code To : Sean Dennis From : mark lewis Date : Fri May 07 2010 10:17 am SD> I couldn't resist relaxing a bit and working on some code, so I got SD> the code finalized and it compiles. Now to see if it actually SD> works. :) here's another post that only pulls out the space delimited fields and this one is zero-based... field 0 is 'A', 1 is 'Daryl', 3 is the comma delimited section and so on... another item of interest about this routine... it looks like, by default, it extracts words that are space, tab or semi-colon (;) delimited... but anyway, there it is :) program extract_word_test; const t1_str : string = 'A Daryl Stout SY,SH,KL,DR,DN,UP,'; t2_str : string = 'PR,MS,MMV,CC,RC,PW,CU,QK,MB,MU,CB,'; t3_str : string = 'TB=05/05/02/01/03/01/01/60/60:120/120 '; t4_str : string = 'LOCAL ANSI 5-4-10 4880 307 18:53'; var my_cnt : integer; my_str, result_str : string; function extractword(str : string; n : integer) : string; var count : integer; i : integer; len : integer; done : boolean; retstr : string; begin retstr := ''; len := length(str); count := -1; i := 1; done := false; while (i <= len) and (not done) do begin while ((i <= len) and ((str[i] = #32) or (str[i] = #9) or (str[i] = ';'))) do inc(i); if i <= len then inc(count); if count = n then begin retstr[0] := #0; if (i > 1) then if str[i-1] = ';' then retstr := ';'; while ((i <= len) and ((str[i] <> #32) and (str[i] <> #9) and (str[i] <> ';'))) do begin inc(retstr[0]); retstr[ord(retstr[0])] := str[i]; inc(i); end; done := true; end else while ((i <= len) and ((str[i] <> #32) and (str[i] <> #9) and (str[i] <> ';'))) do inc(i); end; extractword := retstr; end; begin my_str := t1_str + t2_str + t3_str + t4_str; writeln(my_str); for my_cnt := 0 to 9 do begin result_str := extractword(my_str,my_cnt); writeln(my_cnt, ' : ''',result_str,''''); end; end. * Origin: (1:3634/12) .