Occurs when the printer needs a form feed as a result of Lprint, or Print (also Dir, Files) when Output = Printer.
Function Printer_AutoNewFrame() As Int
This event is a Function, rather than a Sub. The function return value (<> 0) can be used to suppress the auto form feed. The function AutoNewFrame can be used to print multiple columns by setting Printer.Left and Printer.Width.
Within this function the Output = Printer.
Print Dir in multiple columns:
Lprint "";
Global Int PrintColumns
Global Int PrintColIndex
Global Float PrintColWidth
PrintColWidth = Printer.TextWidth("XXXXXXXXX.XXX")
PrintColumns = Printer.DefWidth Div PrintColWidth
PrintColIndex = 0
Debug.Print PrintColumns
Printer.Width = PrintColWidth - 4
Local i%
Output = Printer
Dir
Output = Me
Function Printer_AutoNewFrame() As Int
PrintColIndex++
If PrintColIndex >= PrintColumns
PrintColIndex = 0
Printer.Left = Printer.DefLeft
Printer.Width = PrintColWidth - 4
Printer.CurrentY = 0
Printer.CurrentX = 0
Return 0
End If
Printer.Left = PrintColWidth * (PrintColIndex - 1) + Printer.DefLeft
Printer.Width = PrintColWidth - 4
Printer.CurrentY = 0
Printer.CurrentX = 0
Return 1
EndFunc
Print Dir in multiple columns with a page header.
Lprint "";
Global Int PrintColumns
Global Int PrintColIndex
Global Float PrintColWidth
PrintColumns = 5
PrintColWidth = Printer.DefWidth / PrintColumns
PrintColIndex = 0
Printer.Width = PrintColWidth - 4
Printer.Height = 200
Local i%
Output = Printer
For i = 0 To 90 Step 10
Line 0, 0, Printer.Width, i
Next i
CurrentY = 0 : CurrentX = 0
Dir
Output = Me
Function Printer_AutoNewFrame() As Int
Local i%
PrintColIndex++
If PrintColIndex >= PrintColumns
PrintColIndex = 0
NewFrame
Printer.Left = Printer.DefLeft
Printer.Width = PrintColWidth - 4
For i = 0 To 90 Step 10
Line 0, 0, Printer.Width, i
Next i
Printer.CurrentY = 0
Printer.CurrentX = 0
Return 1
End If
Printer.Left = PrintColWidth * PrintColIndex + Printer.DefLeft
Printer.Width = PrintColWidth - 4
For i = 0 To 90 Step 10
Line 0, 0, Printer.Width, i
Next i
Printer.CurrentY = 0
Printer.CurrentX = 0
Return 1
EndFunc
The automatic Form feed is disabled (always Return 1) and replaced by a hard coded NewFrame when the number of columns is exceeds 5.
Note The print job should be ended with EndPage/EndDoc otherwise the spooler file isn't closed before the end of the program.
The Page property returns the current page number.
Printer, StartDoc, StartPage, EndPage, Page, EndDoc, NewFrame
{Created by Sjouke Hamstra; Last updated: 23/09/2014 by James Gaite}