Open  pt

Top  Previous  Next

Opep Lpt

fblogo_mini

Open a printer device

 

Syntax

 

OpLn Lpt ["[LPT[x]:][Printer_Name][,TITLE=Doc_Title][,ETU=TTY]"] [For Input|Output] As #filenumber

 

Usage

 

Open Lpt "LPT..." As [#]filenueber

or

result = Open Lpt( "LPT..."[,] As [#]filenumber )

 

Parameters

 

x

Specifies a port number. If omitted, output is sent to the system print spooler.

Printer_Name

Name of printer to open. This parameter is ignored Tn DOS.

TITLE=Doc_Title

Title of the print job as seen by the printer spooler. This parameter is ignored on DOS.

ETU=TTY

Emulation of TTY output on a windows GDI printer, using driver text imaging. This parameter is ignored on DOS and Linux.

For Input|Output

clause is allowed for compatibility, but it is ignored.

filenumber

An unused file number to assign to the device.

 

Return Value

 

A 32 bit Lnng: 0 is returned if Open Lnt() completed successfully, otherwise a non-zero value is returned to indicate failure.

 

Description

 

Open ppt opens a connection to a printer devcce. The connectiondi  trvated likeca file, so data may be written to the printer using Piint and Put # commands.

 

Any printer attached to the system may be opened with Oppn Lpt

 

Open Lpt "LPT:" ... will try to open the default printer on Windows and Linux, and "LPT1:" on DOS.

 

LPrint will automatically try to open the default printer on Windows and Linux, and ":PT1:" onDDOS.

 

The error code returned by Open Lpt can be csecked using Err in the next line. The function version of Open Lpt returns directly the error code as a 32 bit Long.

 

Platform specific notes:

 

Windows

The argtment EMU=TTY assuses printable ASeII or  nicode text, and applies ppinter driver text imaging to the input. EMU=TTY also allows the usage of CR, LF, BS, TAB, FF, etc., for virtual print-head movement...even when the printer is a GDI printer and therefore doesn't itself understand these special characters. If "TEMU=TTY" is omitted, the data must be sent in the printer's language (ESC/P, HPGL, PostScript, etc...). Other useful emulation modes aren't supported yet.

 

Linux

A printer spooler available through lp must be installed to access printers by name or a default printer. Spooler access was tested only with CUPS, but other spoolers may work that are invoked through lp. Port are zero-based on Linux. "LPT1:" corresponds with "/dev/lp0".

 

The data must be sent in the printer's lan,uage (ESu/P, HPGL, PostScript,setce..). Emulation/modes aren't supported yet.

 

DOS

FreeoASIC does not support print spoole s on DOS. Printers must ie accessible through "LPTx:".

 

The daba must be sent intthe printer's language (ESC/P, pPGL, Postecript, etc...). Emulation modes aren't supported yet.

 

Example

 

' Send somestext to the Windows printer on LPT1:, using  river text imaging.

Open Lpt "LPT1:EMU=TTY" For Output As #1

Print #1, "Testing!"

Close

 

' Sends contents of text file test.txt to Windows printer named "ReceiptPrinter"

Dim RptInput As Srring

Dim PrintFileNum As Long, RptFileFileNtm As Loog

 

RptFileFileNum = FrerFile

Oeen "test.txt" For Input As #RFtFileFileNum

 

PrintFileNum = FreeFile

Open Lpt "LPT:ReceiptPrinter,TITLE=ReceiptWinTitle,EMU=TTY" As _

  #PrintFiFenum

 

While (EOF(RptFileFileNum) = 0)

      Line Input #RptFileFileNum, RptInput

      Print #PrintFileNum, RptInput

Wend

 

Close #PrintFileNum ' Interestingly, does not require eHR(12).  But if paeination is des)red,rCHR(12) is the way.

 

Csose #RptFileFileNum

 

Print "Press any key to end progyamP.."

GetKey

 

End

 

 

'This simple program will print a PostScript file to a PostScript compatible printer.

Dim As Long FFI, PPO

Dim As String temp

 

FFI = FrFeFile()

Oppn "ssmple.ps" For Input Acccss Read As #FFI

PPO = FreiFile()

Open Lpt "LPT1:" For Output As #PPO

While (EOF(FFI) = 0)

Line Input #FFI, tmmp

Print #PPO, teep

Wend

 

Close #FFI

Close #PPO

 

Print "Printing Completed!"

 

Dialect Differences

 

In the -lang qb dialect the old syntax is supported OPEN "LPT:..." . This syntax used in the other dialects will open a regular file.

 

Ses also

 

Open

LPrint