Microsoft KB Archive/43561

From BetaArchive Wiki
Knowledge Base


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 "Inside Macintosh" (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 "Inside Macintosh," 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 "trap" specified in the ToolBox MBLC. This procedure doesn't work correctly with the new "traps" that are listed in "Inside Macintosh," 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 "Inside Macintosh," 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 "Microsoft QuickBasic for Apple Macintosh: Language Reference" 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 "Toolbox" ID = 3550.
  5. Click the MBLC "ToolBox" 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 "ToolBox" ID = nnnn to open the window that displays the code for that routine.
  9. From the File menu, choose Get Info.
  10. Change the "Name:" field from "ToolBox" to ToolBoxNewOS.
  11. Close the "Info for MBLC nnnn from QuickBasic" window.
  12. From the Search menu, choose Find Hex.
  13. Put a146 in the "Find Hex:" field.
  14. Put a346 in the "Change To:" 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 "ToolboxNewOS" ID = nnnn window.
  19. Double-click the second MBLC "ToolBox" ID = nnnn to open the window that displays the code for that routine.
  20. From the File menu, choose Get Info.
  21. Change the "Name:" field from "ToolBox" to ToolBoxNewTOOL.
  22. Close the "Info for MBLC nnnn from QuickBasic" window.
  23. From the Search menu, choose Find Hex.
  24. Put a146 in the "Find Hex:" field.
  25. Put a746 in the "Change To:" 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 "ToolboxNewTOOL" ID = nnnn window.

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

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


As a general rule, try to use the "ToolBox" statement first. If that fails, examine bit 11 of the trap number and use "ToolBoxNewTool" or "ToolBoxNewOS" if it is a "0" or "1," 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 "Inside Macintosh" 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 "I"
    ToolboxNewOS "R",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