Consultor Eletrônico



Kbase P105334: 4GL/ABL: A form feed character, CHR(12), is generated at the end with OUTPUT TO PRINTER PAGE-SIZE 0.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   17/04/2009
Status: Verified

SYMPTOM(s):

4GL/ABL: A form feed character, CHR(12), is generated at the end with OUTPUT TO PRINTER PAGE-SIZE 0.

Executing the following snippet under a graphical ( GUI ) client ( prowin32.exe ) generates a form feed at the end:
OUTPUT TO PRINTER PAGE-SIZE 0.
PUT UNFORMATTED "Hello".
OUTPUT CLOSE.
The output in hex is: "48 65 6C 6C 6F 0C". Notice that the form feed character, "0C" is generated at the end.

Last write to output is PUT without a SKIP.

Last write does not send the carriage return character , CHR(13). and the line feed character, CHR(10) to the output stream.

The issue exists only when the Windows graphical ( GUI ) client ( prowin32.exe ) is used.

FACT(s) (Environment):

The issue does not exist when the character ( CHUI or TTY ) client ( _progres.exe ) is used.
Executing the following snippet under a character ( CHUI or TTY ) client ( _progres.exe ) does not generate a form feed at the end:
OUTPUT TO PRINTER PAGE-SIZE 0.
PUT UNFORMATTED "Hello".
OUTPUT CLOSE.
The output in hex is: "48 65 6C 6C 6F". Notice that the form feed character, "0C" is not generated at the end.
If a SKIP is the last character output, form feed character, "0C", is not generated. For example, executing the following snippet a graphical ( GUI ) client ( prowin32.exe ) does not generate a form feed at the end:
OUTPUT TO PRINTER PAGE-SIZE 0.
PUT UNFORMATTED "Hello" SKIP.
OUTPUT CLOSE.
The output in hex is without the form feed character, "0C" is not generated at the end: "48 65 6C 6C 6F".
Windows
Progress 9.x
OpenEdge 10.x

CAUSE:

Bug# OE00116839

CAUSE:

This is not a bug. It is the expected behavior. The online documentation of the PAGE-SIZE function states: "If you specify PAGE-SIZE 0, the output is not paged in character mode; in a graphical interface, the default page size is used."

FIX:

One way to prevent the form feed character, CHR(12), from being written at the end of the output stream is to send the data directly to the printer when using a character ( TTY ) client and to an intermediate file, then to the printer when using a graphical (GUI) client. For example:
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
&IF "{&WINDOW-SYSTEM}" = "TTY" &THEN
OUTPUT TO PRINTER PAGE-SIZE 0.
&ELSE
DO:
cFileName = SESSION:TEMP-DIR + "my-file-name" + ".txt".
OUTPUT TO VALUE(cFileName).
END.
&ENDIF
PUT UNFORMATTED "this line will print without a terminating form feed character".
OUTPUT CLOSE.
&IF "{&WINDOW-SYSTEM}" <> "TTY" &THEN
OS-COPY VALUE(cFileName) VALUE(SESSION:PRINTER-PORT).
OS-DELETE VALUE(cFileName).
&ENDIF
Another way to prevent the form feed character, CHR(12), from being written at the end of the output stream when using OUTPUT TO PRINTER PAGE-SIZE 0., is to ensure that the last characters sent to the stream are the carriage return, CHR(13). and the line feed, CHR(10). For example using the SKIP option with the last PUT statement:
OUTPUT TO PRINTER PAGE-SIZE 0.
PUT UNFORMATTED "Hello" SKIP.
OUTPUT CLOSE.
A third way is to explicitly send the carriage return and the line feed pair at the end of the output stream. For example:
DEFINE VARIABLE cTerminator AS CHARACTER NO-UNDO.
ASSIGN
cTerminator = CHR(13) + CHR(10).
OUTPUT TO PRINTER PAGE-SIZE 0.
PUT UNFORMATTED "Hello" cTerminator.
OUTPUT CLOSE.