Kbase P114358: How to output / print the contents of a text EDITOR Widget a line at a time without the extra blank
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  18/03/2006 |
|
Status: Unverified
GOAL:
How to output / print the contents of a text EDITOR Widget a line at a time without the extra blank line at the end?
GOAL:
How to not to print the last last extra blank line when using DISPLAY with an Editor Widget?
FIX:
This following code shows one way of outputting the contents of an EDITOR widget without outputting an extra blank line at the end. The contents of the EDITOR widget are first output to a file, then to a list, then again to the file for the final result:
DO:
DEFINE VARIABLE cAllText AS CHARACTER NO-UNDO.
DEFINE VARIABLE iNumLines AS INTEGER NO-UNDO.
DEFINE VARIABLE cOneLine AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
ASSIGN
Customer.Comments.
OUTPUT TO TempFile.txt.
DISPLAY
Customer.Comments VIEW-AS EDITOR INNER-LINES 1 INNER-CHARS 65
WITH NO-BOX NO-LABELS NO-ATTR-SPACE STREAM-IO.
OUTPUT CLOSE.
ASSIGN
cAllText = "".
INPUT FROM TempFile.txt.
REPEAT:
IMPORT UNFORMATTED cOneLine.
cAllText = cAllText + chr(1) + cOneLine.
END.
INPUT CLOSE.
ASSIGN
cAllText = LEFT-TRIM(cAllText, chr(1))
iNumLines = NUM-ENTRIES(cAllText, chr(1)).
OUTPUT TO myFile.txt.
DO iCounter = 1 TO iNumLines:
ASSIGN
cOneLine = ENTRY(iCounter, cAllText, CHR(1)).
IF iCounter <> iNumLines THEN
PUT UNFORMATTED cOneLine SKIP.
ELSE
PUT UNFORMATTED cOneLine.
END.
OUTPUT CLOSE.
END.