Reference Manual - Table of Contents

Execution Control
Forms and Windows
Controls
Menus
System and Desktop
Graphic Drawing Commands

Animation
QuickTime Movies
Speech
Sound
File I/O
Printing
Serial Ports

Math Functions
String Functions
Date and Time
Memory Buffers
Error Handling
Console Text Window

Events

Direct Memory Access
Direct Mouse Access
Direct Keyboard Access
Code Resource Modules

A - Runtime Error Messages
B - Compiler Error Messages

Printing

This section describes how to send text and images to a printer in Visual MacStandardBasic.

 

Command Summary:
PrintOpen
PrintClose
NewPage

Function Summary:
var = PageSetup( )
var = PrintSetup( )

 

PrintOpen

This command will indicates that a new document will be sent to the printer. This command must be used before attempting to create a print document. This first page of the print document is now ready for text and graphics to be printed.

If there is more than one page in the print document, use the NewPage command to indicate the end of the current page and create the next page.

 

PrintClose

This command will indicates that the current print document is complete and should be sent to the printer.

 

NewPage

This command is used in multiple page print documents. Use the NewPage command to indicate the end of the current page and create the next page.

 

var = PageSetup( )

This function will prompt the user with the standard printer Page Setup Window. The value returned in var will indicate whether the user canceled this operation.

return values for var

1 = This selected the Ok command button.
0 = This selected the Cancel command button.
-1 = Error - A print document has not been opened.

 

var = PrintSetup( )

This function will prompt the user with the standard printer Printer Setup Window. The value returned in var will indicate whether the user canceled this operation.

return values for var

1 = This selected the Print command button.
0 = This selected the Cancel command button.
-1 = Error - A print document has not been opened.

 

Example of Printing Contents of a TextBox

'Assumes that you are using control TextBox1
Sub PrintDocument( )
Dim a, ctr, y, buflen, bufpos, buf$[33000],   linebuf$[256]
buflen = TextLen( TextBox1 )
if buflen = 0 then ExitSub
a = PageSetup()  ' This function will return 1 if user clicked on OK
if a<> 1 then ExitSub
buf$ = CtlText( TextBox1 )
a = 1
PrintOpen
bufpos = 1
Do While a = 1
For y = 1 to 50
' Get line without CR from buffer variable
linebuf$ = ""
Do While Mid( buf$, bufpos,1 ) <> chr(13)   and bufpos <= buflen 

linebuf$ = Left( linebuf$ + Mid( buf$, bufpos,1   ), 256 )
bufpos = bufpos + 1
Loop
DrawText	PRN, 10,y*12, linebuf$
If bufpos > buflen Then a = 0: y=100
bufpos = bufpos + 1		' Skip CR

Next y
a = 0

Loop
PrintClose
EndSub