Другой подход:
define variable t as character no-undo.
define variable x as character no-undo format "x(36)".
define variable i as integer no-undo.
define variable n as integer no-undo.
t = "Many districts and landmarks in New York City are well known, and the city received a record 62.8 million tourists in 2017".
n = num-entries( t, " " ).
do i = 1 to n:
if length( x + entry( i, t, " " )) < 35 then
do:
x = x + entry( i, t, " " ) + " ".
next.
end.
display x with frame a down.
down 1 with frame a.
x = entry( i, t, " " ) + " ".
end.
display x with frame a down.
или, если вы предпочитаете переменную со встроенными символами новой строки:
define variable t as character no-undo.
define variable x as character no-undo format "x(36)".
define variable i as integer no-undo.
define variable j as integer no-undo.
define variable n as integer no-undo.
t = "Many districts and landmarks in New York City are well known, and the city received a record 62.8 million tourists in 2017".
n = num-entries( t, " " ).
do i = 1 to n:
if j < 35 and
(j + length( entry( i, t, " " )) + 1) < 35 then
do:
x = x + entry( i, t, " " ) + " ".
j = j + length( entry( i, t, " " )) + 1.
next.
end.
j = length( entry( i, t, " " )) + 1.
x = x + "~n" + entry( i, t, " " ) + " ".
end.
display x view-as editor size 40 by 10.