declare text character (300) varying; declare word character (20) varying; declare justification character (1); declare k fixed binary; declare input file, output file output; open file (input) title ( '/CENTER.DAT,type(text),recsize(1000)' ); open file (output) title ( '/OUT.TXT,type(text),recsize(1000)' ); on endfile (input) stop; display ('Specify whether justification is left, centered, or right'); display ('Reply with a single letter: L, C, or R'); get edit (justification) (A(1)); do forever; get file (input) edit (text) (L); put skip list (text); text = trim(text, '$', '$'); do until (k = 0); k = index(text, '$'); if k = 0 then /* last word in line */ word = text; else do; word = substr(text, 1, k-1); text = substr(text, k); text = trim(text, '$'); end; select (justification); when ('C', 'c') word = center(word, maxlength(word)); when ('R', 'r') word = right (word, maxlength(word)); otherwise ; /* The default is left adjusted. */ end; put file (output) edit (word) (a(maxlength(word))); end; put file (output) skip; end;