Microsoft KB Archive/45444

= Macintosh QuickBASIC Example for PicComment Is Incomplete =

Article ID: 45444

Article Last Modified on 11/21/2006



This article was previously published under Q45444



SUMMARY
The example for the PicComment ROM trap on Page 517 in the &quot;Microsoft QuickBASIC for Apple Macintosh: Language Reference&quot; 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:


 * 1) 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.
 * 2) 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.
 * 3) The OpenPicture statement gives you a &quot;Type Mismatch&quot; error if you fail to add the statement H&=0 to initialize the H& handle.
 * 4) You get an &quot;Invalid Function CALL&quot; error if you forget to invoke Toolbox &quot;I&quot; 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 &quot;I&quot; ' Must first Initialize the Toolbox.

' Invoke PicComment ROM traps to insert a comment in the ' picture: ToolBox &quot;P&quot;,TrapNo%,190,0,0& ToolBox &quot;P&quot;,TrapNo%,194,0,0& DRAWTEXT &quot;initclip clippath stroke&quot; ' Postscript commands go                                        ' here. ToolBox &quot;P&quot;,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 &quot;LPT1:PROMPT&quot; 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 &quot;I&quot; ' Must first Initialize the Toolbox.

' Invoke PicComment ROM traps to insert a comment in the ' picture: ToolBox &quot;P&quot;,TrapNo%,190,0,0& ToolBox &quot;P&quot;,TrapNo%,194,0,0& DrawText &quot;initclip clippath stroke&quot; ' Postscript commands go                                        ' here. ToolBox &quot;P&quot;,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 &quot;LPT1:PROMPT&quot; FOR OUTPUT AS #1 WINDOW OUTPUT #1 ' Redirect window output to the printer. PICTURE ,A$  ' Send the picture to the printer. CLOSE

Additional query words: MQuickB

Keywords: KB45444

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.