Examples

The printer control commands are supported in Reflection printer sessions. The first example shown here must be run from a printer session. The second example uses a dummy printer session to allow the macro to be run from a terminal session.

Using printer control commands within a printer session

This macro must be run from a Reflection printer session.

Sub ReadFileAndPrintFromPrinterSession()

Dim nextline As String

Dim FiletoPrint As String

 

FiletoPrint = "C:\Mypath\test.txt"

Open FiletoPrint For Input As #1

 

With Session

Do Until EOF(1)

Line Input #1, nextline

.PrintString nextline

.PrintControl rcNewLine

Loop

 

.PrintControl rcEndOfJob

' Flush the printer buffer and close the printer/file

 

Close #1

 

End With

End Sub

 

Using printer control commands from a terminal session

This macro can be run from any Reflection session. It uses a dummy printer session to perform the printer control actions. To use the macro as written, you must first create and save a Reflection printer session named Dummy_print.rsf. This can be either a 3270 or 5250 printer session. The printer session does not need to be connected to a host.

Sub ReadFileAndPrintFromTerminalSession()

 

Dim printerSession As New Reflection.Session

Dim Nextline As String

Dim FiletoPrint As String

 

FiletoPrint = "C:\Mypath\test.txt"

 

With printerSession

.OpenSettings rcSettings, "Dummy_print.rsf"

' The printer session does not need to be connected to a host.

 

Open FiletoPrint For Input As #1

 

Do Until EOF(1)

Line Input #1, Nextline

.PrintString Nextline

.PrintControl rcNewLine

Loop

 

Close #1

 

' Flush the printer buffer and close the printer/file

.PrintControl rcEndOfJob

End With

 

End Sub