Function PCol() Foundation
Determines column position of the print head.
PCol() --> nColumn
The return value of PCol() is a positive integer which corresponds to the current print column+1. The first column position is on the left and has the value zero.
The environment function PCol() determines the column position of the print head. The function manages an internal counter which counts the characters sent to the printer. This counter is updated only when the output to the printer occurs due to SET DEVICE TO PRINTER or SET PRINTER ON. The internal counter has the value zero at the start of the program. Following a Carriage-Return (Chr(13)) and the command EJECT, which sends a Form-Feed Chr(12) to the printer, the counter is reset to zero. For any other character, the counter is incremented by one. When a left margin is set with the command SET MARGIN, the internal counter is not set to zero, but to the number of characters of the left margin.
When unprintable characters or control characters (escape sequences) are sent to the printer, the internal counter of PCol() differs from the actual position of the print head. PCol() counts control characters which are interpreted by the printer and not printed. In this case the value of PCol() (and PRow()) must be saved before output so that it can be reset with the function SetPrc() after output of the control characters.
The function PCol() is used along with the function PRow() for formatting the output of forms or tables where the print position is relative to the last position of the print head.
// In the example the data records of a parts file are printed out
// using PCol().
PROCEDURE Main
LOCAL nLine := 66
LOCAL nPageLen := 65
LOCAL nPageNum := 0
USE Parts NEW EXCLUSIVE
INDEX ON PartNo TO PartsA
SET DEVICE TO PRINTER
DO WHILE .NOT. Eof()
IF nLine > nPageLen
EJECT
nLine := 1
nPageNum++
@ nLine, 60 SAY "Page Num: " + LTrim(Str(nPageNum))
nLine := 3
ENDIF
@ nLine, 0 SAY PartNo
@ nLine, PCol() + 3 SAY Part
@ nLine, PCol() + 3 SAY Price PICTURE "@$ 99,999.99"
SKIP
nLine++
ENDDO
SET DEVICE TO SCREEN
CLOSE Parts
RETURN
// In the example, the function PrintEscSequence() is programmed
// so that the position of the print head corresponds to PCol(),
// when control characters are output. Codes assoicated with
// Epson printers are used as the control characters.
PROCEDURE Main
SET DEVICE TO PRINTER
@ 0,0 SAY "Normal text"
PrintEscSequence( Chr(27)+Chr(69) ) // Bold type ON
@ 0,PCol() + 1 SAY "Bold type text"
PrintEscSequence( Chr(27)+Chr(70) ) // Bold type OFF
PrintEscSequence( Chr(27)+Chr(52) ) // Italics ON
@ 0,PCol() + 1 SAY "Italic type Text"
PrintEscSequence( Chr(27)+Chr(53) ) // Italics OFF
EJECT
SET DEVICE TO SCREEN
RETURN
FUNCTION PrintEscSequence( cEscSeq )
LOCAL nRow := PRow(), nCol := PCol()
?? cEscSeq
RETURN SetPrc( nRow, nCol )
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.