Consultor Eletrônico



Kbase P124912: 4GL/ABL: When does the SKIP option of the PUT statement start a new line?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/3/2009
Status: Verified

GOAL:

4GL/ABL: When does the SKIP option of the PUT statement start a new line?

GOAL:

When does the SKIP option of the PUT statement generate an End Of Line (EOL) character?

GOAL:

Does the CONTROL option of the PUT statement increment the column counter of the output stream?

GOAL:

Why do the two highlighted PUT statements in the following snippet NOT generate new lines between the "First line" and the "Last line" in the following code?
DEFINE VARIABLE iVariable AS INTEGER NO-UNDO.
OUTPUT TO test.txt.
PUT UNFORMATTED "First line" SKIP.
PUT UNFORMATTED SKIP.
PUT UNFORMATTED SKIP(0).
PUT UNFORMATTED "Last line" SKIP.
OUTPUT CLOSE.

FACT(s) (Environment):

All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

The syntax of the SKIP option of the PUT statement is SKIP and optionally SKIP(n) where n is the number of new lines to be output. If PUT SKIP or PUT SKIP(0) is used, then Progress starts a new line to the output stream ONLY if output is NOT already positioned at the beginning of a new line. Examples:
1. The statement:
PUT UNFORMATTED "First line" SKIP.
generates a EOL character (CR/LF on Windows, LF on UNIX) because output is not positioned at the beginning of a new line after it outputs the string "First line".
2. While the second and third statement in the following snippet
PUT UNFORMATTED "First line" SKIP.
PUT UNFORMATTED SKIP.
PUT UNFORMATTED SKIP(0).

do NOT generate new lines since the first statement: 'PUT UNFORMATTED "First line" SKIP.' has already positioned the output at the beginning of a new line.
In summary, the SKIP[(n)] option of the PUT statement will generate n End Of Line (EOL) character(s) if the parameter n is greater than zero and the output stream is at the beginning of a new line and it will generate n + 1 (EOL) character(s) if the output stream is NOT at the beginning of a new line.
Using the CONTROL option of the PUT statement does not affect the current line, page counters, and positions. As a consequence. For example:
3. The PUT SKIP(3) statement in the following snippet will generate 4 (EOL) characters because output it is NOT at the beginning of a new line:
PUT "1".
PUT SKIP(3).
4. The PUT SKIP(3) statement in the following snippet will generate 3 (EOL) characters because output IS at the beginning of a new line since the PUT CONTROL does not increment the position of the cursor of the output stream:
PUT CONTROL "1". /* Output stream does not advance because of the CONTROL option */
PUT SKIP(3). /* Generates 3 EOL characters one of which is at the end of the first line */