Futurebasic/Language/Reference/route

Syntax
To re-route text and graphics:

ROUTE [#]_toPrinter

ROUTE [#]_toScreen

ROUTE [#]_toBuffer [+ 0... 4 ]

To re-route text:

ROUTE [#]serialPort

ROUTE [#]fileID

Revised
May, 2001 (Release 5)

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 FB 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 FB 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: HelloGoodbye 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 DEF DISPOSEH.

DEF DISPOSEH(gFBbuffer(2)) FB Lite behavior: When you use the "FB Lite" runtime, built-in graphics statements such as BOX, CIRCLE and PLOT are always directed to the Graphics Window; using ROUTE _toPrinter won't cause such commands to be directed to the printer. If you want to send graphics to the printer while using "FB Lite," first execute ROUTE _toPrinter, then use QuickDraw Toolbox routines such as FRAMERECT, FRAMEOVAL, LINETO, etc.

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.