BCX Printer Procedures


OPEN "PRN"

OPEN "PRN" can be used to send data to a printer. OPEN will make a connection to the printer using a handle to "PRN", the standard printer communications device. The data then is output to the printer using a PRINT statement. Here is a simple example for sending data to the default printer.

Example:

DIM i

OPEN "PRN" FOR OUTPUT AS FP1

FOR i = 1 TO 60
  PRINT FP1,"This is line number", i
NEXT

PRINT FP1, CHR$(12) 'CHR$(12) is Form Feed Character

CLOSE FP1

PRINTER OPEN statement

LPRINT statement

PRINTER CLOSE statement

Purpose:

LPRINTprints directly only to LPT1. Anything that you can PRINT and FPRINT, you can also LPRINT. The PRINTER OPEN statement must precede LPRINT and PRINTER CLOSE follow to close the printer port.

Syntax:

PRINTER OPEN [, FontName AS STRING] _
            [, FontSize AS INTEGER] _
        [, CharacterSet AS INTEGER]
LPRINT comma separated expressions
PRINTER CLOSE

Parameters:

  • Data type: STRING
    FontName [OPTIONAL] is a string variable or literal specifying the font to be used. The default font is Courier New.
  • Data type: INTEGER
    FontSize [OPTIONAL] is an integer specifying the font size to be used. The default size is 12.
  • Data type: INTEGER
    CharacterSet [OPTIONAL] is an integer specifying the character set to be used. The default is the integer defined as DEFAULT_CHARSET.
  • comma separated expressions Expressions to be printed. Each line of comma separated expressions sent to LPRINT is limited to 2048 bytes.

Example:

A simple LPRINT demonstration:

PRINTER OPEN

FOR INTEGER i = 1 to 50
 LPRINT "This is line number ", i , ".  BCX matures again!"
NEXT

LPRINT CHR$(12) ' Form Feed(eject from paper printer)

PRINTER CLOSE

PRINTER EJECTPAGE statement

Purpose:

The PRINTER EJECTPAGE statement notifies the printer that the application has finished writing to a page. This statement is used to tell the printer to eject the page. The PRINTER OPEN and LPRINT statements must precede PRINTER EJECTPAGE and PRINTER CLOSE follow to close the printer port.

Syntax:

PRINTER OPEN
LPRINT comma separated expressions
PRINTER EJECTPAGE
PRINTER CLOSE

Parameters:

  • comma separated expressions Expressions to be printed. Each line of comma separated expressions sent to LPRINT is limited to 2048 bytes.

Here is a second method to print to a printer. BCX opens a connection to the printer using a handle to PRN, a standard printer communications device. The data then is output to the printer using a PRINT statement. LPT1 should also work instead of PRN.

Example:

Here is a simple example for sending data to the default printer.

DIM i

OPEN "PRN" FOR OUTPUT AS FP1

FOR i = 1 TO 60
 PRINT #FP1, "This is line number" , i
NEXT

PRINT #FP1, CHR$(12) 'CHR$(12) is Form Feed Character

CLOSE FP1