The only reasonable way of doing this is to use Can Grow, which will automatically set up the word-wrap for you. Part of the issue is that if you're using a proportional font (MOST fonts ARE proportional - Courier New is one exception) each letter has it's own width. So, for example, 60 characters with lots of l's and i's will be much narrower than 60 characters with lots of m's and w's. If you're using a non-proportional font, you might be able to do something similar to this:
Stringvar c;Numbervar at := 60;Stringvar result := '';
if length({string field}) < 60 then
result := {string field};
else
c := mid({string field}, at, 1);
While c <> ' ' and at > 0 do
(
at := at - 1;
c := mid({string field}, at, 1);
);
if at = 0 then
result := {string field};
else
result = left({string field}, at) + chr(13) + chr(10) +
mid({string field}, at + 1, length({string field});
);
result
Note: I haven't tested this code, so it will probably need to be tweaked. Also, this assumes that there are ONLY 2 lines possible. If there's more than that, you REALLY need to turn on Can Grow and let the auto-word wrap do its thing.
-Dell
Edited by hilfy - 14 Sep 2012 at 9:14am