COLUMN

COLUMN in DISPLAY statements

COLUMN in PRINT statements

COLUMN vs SPACE

COLUMN operator specifies the position of the value which follows this operator on the 4GL screen (DISPLAY) or in the report (PRINT).

When no form is open, width of a value displayed by PRINT and DISPLAY depends on its declared data type (unless the CLIPPED or USING keywords are used).

COLUMN allows a 4gl developer to control the location of items within a line in a REPORT program block or in a DISPLAY statement. It is especially useful when you need to output tabular data.

 

COLUMN operator has one operand. This is a right operand that can be an integer expression or

a literal integer:

LET pos = 10

PRINT COLUMN pos, "I start at column 10"

DISPLAY COLUMN 10, "I start at column 10"

The operand tells Lycia where to position a value relative to the left margin of the 4gl screen or the current 4gl report.

In reports, the operand cannot be greater than the arithmetic difference between the margins = (right marginleft margin) for explicitly specified or default values in the OUTPUT section of the REPORT definition.

If the printing position in the current line is already beyond the specified value of the operand, the COLUMN operator has no effect.

COLUMN in DISPLAY statements

With DISPLAY statements, COLUMN specifies the distance between the first character of the displayed value and the first character position of the 4gl screen.

You cannot use COLUMN to send output to a screen form. A DISPLAY statement that includes the COLUMN operator cannot include AT, TO, BY NAME, or ATTRIBUTE clauses.

When you include the COLUMN operator in a DISPLAY statement, you must specify a literal integer as the left-offset, rather than an integer expression.

In this example program, strings are displayed with increasing indents:

MAIN

DEFINE pos INTEGER

DISPLAY "1234567890123456789012345678901234567890"

DISPLAY COLUMN 10, "I start at column 10"

LET pos = 20

DISPLAY COLUMN pos,"I start at column 20"

DISPLAY COLUMN 30, "I start at column 30"

CALL fgl_getkey()

END MAIN

COLUMN in PRINT statements

When you use the PRINT statement in the FORMAT section of a report, items are printed out one after another and are separated by blank spaces.

COLUMN operator overrides this default positioning. It moves the current character position to the right on the current line of the report page.

 

The required position is calculated as a number of characters between the left side of the report page (excluding the left margin) and the current character position. If the left margin for the report is not specified in the OUTPUT section or in START REPORT, the required position is calculated starting from the left side of the page or screen.

The default position is this:

COLUMN 1

It means that the cursor is positioned at the first character of the current line.

 

The operand of the COLUMN operator cannot be greater than the total width of the report page (excluding the left margin width).

If the operand of the COLUMN operator is smaller than the current character position, this operator is ignored.

 

This example program produces an output similar to the DISPLAY output show above:

MAIN

START REPORT rep1 TO SCREEN

OUTPUT TO REPORT rep1()

FINISH REPORT rep1

END MAIN

 

REPORT rep1()

DEFINE

pos INTEGER

 

OUTPUT LEFT MARGIN 0

 

FORMAT

ON EVERY ROW

PRINT "1234567890123456789012345678901234567890"

PRINT "Start at column 1"

PRINT COLUMN 10, "Start at column 10"

LET pos = 20

PRINT COLUMN pos, "Start at column 20"

PRINT COLUMN 30, "Start at column 30"

LET pos = 40

PRINT COLUMN pos, "Start at column 40"

END REPORT

COLUMN vs SPACE

COLUMN operator can be sometimes confused with the SPACE operator. But if sometimes these two operators can produce the same effect, they are different:

Here COLUMN and SPACE will produce the same output:

PRINT 2 SPACE, "345", 1 SPACE, "78", 1 SPACE, "10"

PRINT COLUMN 2, "345", COLUMN 6, "78", COLUMN 9, "10"

But these outputs will be completely different:

PRINT 5 SPACE, "345", 5 SPACE, "78", 5 SPACE, "10"

PRINT COLUMN 2, "345", COLUMN 10, "78", COLUMN 25, "10"

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.