FutureBasic Logo

<<    Index    >> FutureBasic 5

route   statement



Syntax:
To re-route text and graphics:
route [#]_toPrinter
route [#]_toScreen
route [#]_toBuffer [+ 0... 4 ]

To re-route text:
route [#]serialPort
route [#]fileID


Description:
This statement causes text printed by subsequent print statements to be sent to the indicated device. If you specify _toScreen or _toPrinter, subsequent drawing commands are also sent to the indicated device. If you specify _toBuffer, only text printing commands are sent to the indicated device.

Using route _toPrinter
route _toPrinter opens a new print job unless a print job is already open. When you first open a new print job, the printer adopts the font and graphics characteristics that are in effect in the current screen window. Subsequent print statements, as well as graphics commands such as box, circle and plot, are sent to the printer. Subsequent statements which affect the appearance of text and graphics, such as text, pen and color, apply to the printed output. Subsequent QuickDraw Toolbox commands such as FrameRect apply to the printed output.
Note: To actually put out the current printer page, use the clear lprint statement after sending text and drawing commands to the printer.

Using route _toScreen
After using route to direct output to the printer, or to a serial device or a file, you can use route _toScreen to re-direct output back to the screen window again.
Note: Statements which affect the appearance of text and graphics, such as text, pen and color, apply separately to the screen window and to the printer. The settings in one device don't affect the settings in the other, except when you first open a new print job.

Using route serialPort and route fileID
These statements cause text printed by subsequent print statements to be sent to the specified open device. They don't affect the destination of graphics commands. This group of statements:
route deviceID
print itemList1
print itemList2
:
print itemListN
route _toScreen

has the same effect as this group of statements:
print #deviceID, itemList1
print #deviceID, itemList2
:
print #deviceID, itemListN


Using route _toBuffer
You can use the FutureBasic route _toBuffer statement to print information directly to a handle. You may use any one of five handles by setting the route statement in the range of _toBuffer through _toBuffer + 4. When routed to a buffer, only text commands are sent to the handle. Graphic commands are ignored.
Information printed to a buffer ends up in one of five handles stored as globals in the FutureBasic runtime. This array is named gFBbuffer(n) where n is a numeric expression in the range of 0...4. The following example prints text to buffer number 2.
route _toBuffer + 2
print "Hello"
print "Goodbye"
route _toScreen

When this snippet has been executed, gFBbuffer(2) will contain a handle that points to a moveable block of 14 bytes:
Hello<CR>Goodbye<CR>
Note that carriage returns are added or suppressed in writing to a buffer just as they would be in writing to a file or to the screen.
If you want to dispose of a buffer, use DisposeH.
DisposeH(gFBbuffer(2))

Note:
The window statement and the window output statement implicitly execute a route _toScreen statement. Also, any user action which activates a screen window (such as clicking on its title bar) will implicitly cause a route _toScreen. If you want to make sure that output is not inadvertently directed to the screen window, you should check for _wndActivate events in your dialog-event handling routine, and re-direct the output as necessary.

See Also:
open; print; print#; clear lprint; close lprint; text; pen; color; long color; box; circle; plot; on dialog