Microsoft KB Archive/43561

= How to Create ToolBoxNewOS, ToolBoxNewTool for New ROM Calls =

Article ID: 43561

Article Last Modified on 10/20/2003

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0

-



This article was previously published under Q43561



SUMMARY
Listed below are the steps necessary to create two new Toolbox statements required to access the new ROM routines listed in Volumes IV and V of &quot;Inside Macintosh&quot; (by Apple Computer, published by Addison-Wesley), and revised ROM routines in Volumes I, II, and III.

This information applies to Microsoft QuickBasic versions 1.0, 1.0a, and 1.0b for Apple Macintosh.



MORE INFORMATION
The address of certain ROM routines in &quot;Inside Macintosh,&quot; Volumes IV and V, and revised ROM routines listed in Volumes I, II, and III, are not accessible through the standard Toolbox statement (which is an MBLC routine) packaged with QuickBasic. To call these additional routines, you need to modify Macintosh QuickBasic with the ResEdit utility.

This situation occurs because QuickBasic uses _GetTrapAddress to obtain the address of the &quot;trap&quot; specified in the ToolBox MBLC. This procedure doesn't work correctly with the new &quot;traps&quot; that are listed in &quot;Inside Macintosh,&quot; Volumes IV and V, and for the revised ROM routines in Volumes I, II, and III. For a detailed explanation of how _GetTrapAddress is used, refer to Page 234 of &quot;Inside Macintosh,&quot; Volume IV.

To make all ROM routines accessible to QuickBasic, two new Toolbox library routines need to be created. The two new Toolbox routines are used for the following:


 * Old ROM routines that have not been revised
 * The new Operating System routines
 * The new Toolbox routines

On the second part of this document is an example showing how to use the revised ROM routine NEWPTR. Pages 497-524 of the &quot;Microsoft QuickBasic for Apple Macintosh: Language Reference&quot; manual discuss how to call the existing Toolbox statement.

Use the following steps to create the two new Toolbox statements ToolBoxNewOS and ToolBoxNewTool:


 * 1) Invoke ResEdit.
 * 2) Open QuickBasic (b) or (d).
 * 3) Double-click the MBLC resource in the Microsoft QuickBasic (b) or (d) window.
 * 4) Scroll down to MBLC &quot;Toolbox&quot; ID = 3550.
 * 5) Click the MBLC &quot;ToolBox&quot; ID = 3550.
 * 6) From the Edit menu, choose Duplicate.
 * 7) Choose Duplicate from the Edit menu a second time.
 * 8) Double-click the first MBLC &quot;ToolBox&quot; ID = nnnn to open the window that displays the code for that routine.
 * 9) From the File menu, choose Get Info.
 * 10) Change the &quot;Name:&quot; field from &quot;ToolBox&quot; to ToolBoxNewOS.
 * 11) Close the &quot;Info for MBLC nnnn from QuickBasic&quot; window.
 * 12) From the Search menu, choose Find Hex.
 * 13) Put a146 in the &quot;Find Hex:&quot; field.
 * 14) Put a346 in the &quot;Change To:&quot; field.
 * 15) Choose the Change All button.
 * 16) Choose the OK button in the Alert box.
 * 17) Close the Change Hex window.
 * 18) Close the MBLC &quot;ToolboxNewOS&quot; ID = nnnn window.
 * 19) Double-click the second MBLC &quot;ToolBox&quot; ID = nnnn to open the window that displays the code for that routine.
 * 20) From the File menu, choose Get Info.
 * 21) Change the &quot;Name:&quot; field from &quot;ToolBox&quot; to ToolBoxNewTOOL.
 * 22) Close the &quot;Info for MBLC nnnn from QuickBasic&quot; window.
 * 23) From the Search menu, choose Find Hex.
 * 24) Put a146 in the &quot;Find Hex:&quot; field.
 * 25) Put a746 in the &quot;Change To:&quot; field.
 * 26) Choose the Change All button.
 * 27) Choose the OK button in the Alert box.
 * 28) Close the Change Hex window.
 * 29) Close the MBLC &quot;ToolboxNewTOOL&quot; ID = nnnn window.

The next step is to decide which Toolbox routine should be used. Page 13 of &quot;Inside Macintosh,&quot; Vol. IV, states the following:

Bit 11 of the trap word determines how the remainder of the word will be interpreted; usually it's &quot;0&quot; for Operating System calls and &quot;1&quot; for ToolBox calls, though there can be exceptions.

As a general rule, try to use the &quot;ToolBox&quot; statement first. If that fails, examine bit 11 of the trap number and use &quot;ToolBoxNewTool&quot; or &quot;ToolBoxNewOS&quot; if it is a &quot;0&quot; or &quot;1,&quot; respectively.

For example, because bit 11 of NewPtr is 0, you know that NewPtr is an Operating System call. Listed in the back of Volumes III, IV, and V of &quot;Inside Macintosh&quot; are the SYSTEM TRAPS for each routine call. The number listed is in hexadecimal notation; therefore, the number must be converted into binary so that bit 11 can be checked. The following is an example showing how to allocate a block of memory using Newptr: DIM regsarray&(5) size& = 0 Newptr& = &HA11E ToolboxNewOS &quot;I&quot; ToolboxNewOS &quot;R&quot;,NewPtr&,regsarray&(0),,,(size&) PRINT HEX$(regsarray&(2))     'print out the pointer PRINT regsarray&(0)           'print out the error, 0 if none

Additional query words: MQuickB 1.00 1.00a 1.00b

Keywords: KB43561

-

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

© Microsoft Corporation. All rights reserved.