Macintosh QuickBASIC Example for PicComment Is Incomplete (45444)
This article was previously published under Q45444
SUMMARY
The example for the PicComment ROM trap on Page 517 in the "Microsoft
QuickBASIC for Apple Macintosh: Language Reference" manual is correct,
but is an incomplete code fragment that requires additional statements
to work properly. A working example is shown below.
MORE INFORMATION
The following are some programming notes for using the PicComment
routine on Page 517 of the Macintosh language reference manual:
- Note that parentheses (for passing by value) are not required
around each of the parameters 190%, 194%, 191%, and 0% when calling
the Toolbox routine, since constants are always passed by value
(and not by reference). Only variables require parentheses if you
wish to pass variables by value.
- Note that the QuickBASIC editor automatically strips off the
percent sign (%) on short-integer constants such as 190%, 194%,
191%, and 0%, which all default to a type of short integer.
- The OpenPicture statement gives you a "Type Mismatch" error if
you fail to add the statement H&=0 to initialize the H& handle.
- You get an "Invalid Function CALL" error if you forget to invoke
Toolbox "I" initialization before running this code fragment.
Example 1
Below is a complete, working example of PicComment based upon the
example from Page 517 of the Macintosh language reference manual. This
program requires an Apple LaserWriter. The program draws a circle and
surrounds it with a box drawn around the border of the page using
PostScript commands which are embedded in a picture comment.
TrapNo%=&HA8F2 ' This is the address of the PicComment ROM
' trap.
H&=0
DIM rec%(3)
SetRect rec%(0),1,1,638,750 ' Maximum page size put into array
OpenPicture rec%(0),H& ' Turn on bitmapped picture recording.
ToolBox "I" ' Must first Initialize the Toolbox.
' Invoke PicComment ROM traps to insert a comment in the
' picture:
ToolBox "P",TrapNo%,190,0,0&
ToolBox "P",TrapNo%,194,0,0&
DRAWTEXT "initclip clippath stroke" ' Postscript commands go
' here.
ToolBox "P",TrapNo%,191,0,0&
' Draw any graphics you wish to make a picture:
CIRCLE (100,100),20 ' Draws circle with radius 20.
' Turn off the recording of the picture:
ClosePicture
' Open the printer for graphics mode output:
OPEN "LPT1:PROMPT" FOR OUTPUT AS #1
WINDOW OUTPUT #1 ' Redirect window output to the printer.
DrawPicture H&,rec%(0) ' Send the picture to the printer.
CLOSE
Example 2
Below is a simpler example of PicComment, which uses QuickBASIC's
PICTURE ON and PICTURE OFF statements (instead of the OpenPicture
and ClosePicture MBLC routines used in Example 1). This program
requires an Apple LaserWriter.
TrapNo%=&HA8F2 ' This is the address of the PicComment ROM
' trap.
PICTURE ON ' Turns on recording of a picture.
SHOWPEN ' Lets you see the picture as it is drawn
' (optional).
ToolBox "I" ' Must first Initialize the Toolbox.
' Invoke PicComment ROM traps to insert a comment in the
' picture:
ToolBox "P",TrapNo%,190,0,0&
ToolBox "P",TrapNo%,194,0,0&
DrawText "initclip clippath stroke" ' Postscript commands go
' here.
ToolBox "P",TrapNo%,191,0,0&
' Draw any graphics you wish to make a picture:
CIRCLE (100,100),20 ' Draws circle with radius 20.
PICTURE OFF ' Turn off the recording of the picture.
a$=PICTURE$ ' Retrieve QuickDraw-format picture into a string
' (a$)
' Open the printer for graphics mode output:
OPEN "LPT1:PROMPT" FOR OUTPUT AS #1
WINDOW OUTPUT #1 ' Redirect window output to the printer.
PICTURE ,A$ ' Send the picture to the printer.
CLOSE
Modification Type: |
Minor |
Last Reviewed: |
1/9/2003 |
Keywords: |
KB45444 |
|