/* SayWords
 *
 * output text to the screen,
 * accounting for screen width
 * accounting for word size
 * accounting for embedded cr
 */

SayWords:

pg = arg(1)
tline = ''
do pgn = 1 to words(pg)
   tword = strip(word(pg, pgn), 'Both', ' ')
   if pos(d2c(13), tword) > 0 then do
      tline = tline left(tword, pos(d2c(13), tword) - 1)
      say tline
      tline = substr(tword, lastpos(d2c(13), tword) + 1)
      say ""
   end
   else if length(tline tword) > 79 then do
      say tline
      tline = tword
   end
   else tline = strip(tline tword, 'L', ' ')
end
say tline

return ''
