Hello Emma,
If I understand correctly then the following function should solve your problem. You basically just pass the text on to it and tell it how many characters the seperate pieces of return text can be in length. The function returns the same text to you but split up in pieces, seperated by chr(1) and each piece has the maximum length you have specified.
This then allows you to print the text as you now know that the maximum length of each piece of text will not exceed your page-width.
Hope this solves your problem.
FUNCTION ParseText.
RETURNS CHARACTER
( INPUT charTekst AS CHARACTER,
INPUT intMaxLength AS INTEGER
/* parameter-definitions */ ) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
DEFINE VARIABLE charTekst2 AS CHARACTER NO-UNDO.
DEFINE VARIABLE intCurrentPos AS INTEGER NO-UNDO.
DEFINE VARIABLE intPrevpos AS INTEGER INIT 1 NO-UNDO.
ASSIGN intMaxLength = intMaxLength - 1
intCurrentPos = intMaxLength
charTekst = REPLACE(charTekst,CHR(10),CHR(1))
charTekst = REPLACE(charTekst,CHR(13),CHR(1)).
DO WHILE intCurrentPos < LENGTH(charTekst) + intMaxlength:
DO WHILE SUBSTRING(charTekst,intCurrentPos,1) <> ' ' AND
SUBSTRING(charTekst,intCurrentPos,1) <> ',' AND
SUBSTRING(charTekst,intCurrentPos,1) <> ';' AND
SUBSTRING(charTekst,intCurrentPos,1) <> ':' AND
SUBSTRING(charTekst,intCurrentPos,1) <> '-' AND
SUBSTRING(charTekst,intCurrentPos,1) <> '.' AND
SUBSTRING(charTekst,intCurrentPos,1) <> '?' AND
SUBSTRING(charTekst,intCurrentPos,1) <> '!' AND
SUBSTRING(charTekst,intCurrentPos,1) <> CHR(10) AND
SUBSTRING(charTekst,intCurrentPos,1) <> CHR(13) AND
intCurrentPos > intPrevPos :
ASSIGN intCurrentPos = intCurrentPos - 1.
END.
IF intCurrentPos = intPrevPos THEN
ASSIGN intCurrentPos = intCurrentPos + intMaxLength.
IF charTekst2 = '' THEN
ASSIGN intCurrentPos = intCurrentPos + 1
charTekst2 = SUBSTRING (charTekst,intPrevPos,intCurrentPos - intPrevPos)
intPrevPos = intCurrentPos
intCurrentPos = intCurrentPos + intMaxLength.
ELSE
ASSIGN intCurrentPos = intCurrentPos + 1
charTekst2 = charTekst2 + chr(1) + SUBSTRING (charTekst,intPrevPos,intCurrentPos - intPrevPos)
intPrevPos = intCurrentPos
intCurrentPos = intCurrentPos + intMaxLength.
END.
RETURN charTekst2. /* Function return value. */
END FUNCTION.