Description

The Direct_Print function provides a method to print data directly to a printer. This function bypasses the use of print drivers enabling the use of escape codes to be sent directly to the printer.

Syntax

retVal = Direct_Print(MSG, parameter1, parameters2, ....)

Parameters

The first parameter (MSG) is the message or function that is sent to the printer, and it is required. The remaining parameters are optional parameters that control the behavior of the message.

Returns

A value of '1' is returned by Direct_Print if the function call is successful. A negative value is returned if an error is encountered.

See also

START Direct_Print() message

STOP Direct_Print() message

PRINT Direct_Print() message

PAGE Direct_Print() message

ABORT Direct_Print() message

PRINTBIN Direct_Print() message

Direct_Print Error Codes

Remarks

The START message controls the printer device to be used and print job name for each printing session.

The STOP message will end a print job.

The PAGE message is used to create a page break.

The ABORT message is used to abort the current print job.

The PRINT message is used to send plain text or embedded escape codes to control the output of the printer.

The PRINTBIN message is used to print binary data with embedded nulls.

Example

Subroutine Direct_Print_Example(startValue)
Declare Function Direct_Print, Unassigned
If Unassigned(startValue) Then startValue = ''
Equ HP_Bold$ To char(27):'(s3B'
Equ HP_Norm$ To char(27):'(s-5B'
* This case statement contains the various START options
Begin Case
  Case startValue = ''
    retval = Direct_Print('START','','','') ; * print to default printer
  Case startValue = 'ToFile'
    retval = Direct_Print('START','','C:\TEMP\DIRECT_PRINT_EXAMPLE.TXT',1) ; * Print To file
  Case startValue = 'Different_Printer'
    retval = Direct_Print('START','HP LaserJet 2200 Series PCL 6','','') ; * print to a specific printer
End case
If retval < 1 then Goto ErrorHandler
* Print 30 lines of bold text
For i = 1 To 30
  retval = Direct_Print('PRINT',HP_Bold$:'This first page contains bold text.')
  If retval < 1 then Goto ErrorHandler
Next i
retval = Direct_Print('PAGE') ; * Force page break
If retval < 1 then Goto ErrorHandler
For i = 1 To 30
  retval = Direct_Print('PRINT',HP_Norm$:'This page contains plain text.')
  If retval < 1 then Goto ErrorHandler
Next i
retval = Direct_Print('PAGE') ; * Force page break
If retval < 1 then Goto ErrorHandler
retval = Direct_Print('PRINT','This page contains concatenated text.',0)
If retval < 1 then Goto ErrorHandler
retval = Direct_Print('PRINT','This page contains concatenated text.',1)
If retval < 1 then Goto ErrorHandler
* End the Print Job
retval = Direct_Print('STOP')
ErrorHandler:
If retval < 1 Then
  Swap @fm With  @vm In retval
  call Msg(@Window,'ERROR':retval)
  retval = Direct_Print('ABORT')
End
Return
  • No labels