Microsoft KB Archive/48057

= Adding ToolBox Type Checking to QuickBASIC's MBTS Resource =

Article ID: 48057

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0

-



This article was previously published under Q48057



SUMMARY
This article describes how to add argument type-checking in QuickBASIC's &quot;MBTS&quot; resource for additional routines so that the Q option can be left off of the ToolBox call. This article expands upon Section E.10.3.3, &quot;Argument Checking&quot; on pages 502 to 503 of the &quot;Microsoft QuickBASIC for Apple Macintosh: Language Reference&quot; manual.

This information applies to Microsoft QuickBASIC version 1.00 for Apple Macintosh systems.



MORE INFORMATION
The &quot;MBTS&quot; resource in Microsoft QuickBASIC version 1.00 currently comes with the trap numbers, call types, and variable types defined for 29 ROM routine calls. You can add argument checking for more (or all) of the Macintosh ROM routines to this resource by using ResEdit supplied with Microsoft QuickBASIC.

Note: Use ResEdit, supplied with Microsoft QuickBASIC 1.00. It can be found on the Examples disk in the Tools folder.

By adding commonly-used ToolBox calls to the &quot;MBTS&quot; resource stored in both the binary and decimal versions of QuickBASIC, you can avoid the necessity of adding a &quot;Q&quot; in the Toolbox call argument.

As mentioned on page 499, you normally add a&quot;Q&quot; to the calltype$ string of the ToolBox statement to skip argument checking and call routines not listed in QuickBASIC's &quot;MBTS&quot; resource. If you know exactly what parameters to pass, using &quot;Q&quot; is not a problem; however, one danger of using &quot;Q&quot; is that improperly passed parameters are not trapped, and can make the ToolBox statement hang or crash with a System Error.

Steps and Code Examples
The following example program invokes ToolBox statements with a &quot;Q&quot; to avoid type checking for four ROM traps. Below that is a series of steps showing how to use ResEdit to add argument-checking to QuickBASIC's MBTS resource so the four ROM traps can be invoked without the &quot;Q&quot;. MenuID% = 100 MH& = 0 NewTrap& = &HA931 AppendTrap& = &HA933 InsertTrap& = &HA935 DrawTrap& = &HA937 ToolBox &quot;i&quot; ToolBox &quot;LQ&quot;, NewTrap&,(MenuID%),(&quot;OPTIONS&quot;),MH& ToolBox &quot;PQ&quot;, AppendTrap&,(MH&),(&quot;Option 1;Option 2&quot;) ToolBox &quot;PQ&quot;, InsertTrap&,(MH&),(0) ToolBox &quot;PQ&quot;, DrawTrap& WHILE MOUSE(0) <> 1 : WEND END Before starting, it is best to gather all the information needed prior to entering ResEdit to add the argument-checking information. You first need the trap number (in Hex), the call type, and the argument types for each ROM call. The call types and argument types can be obtained from the two charts on page 503. For this example, the information is listed below:   Procedure        Trap       Call Type        Argument Type(s) -              -

AppendMenu      A933           0              2  4 InsertMenu      A935           0              2  0 NewTrap         A931           4              0  4  3 DrawMenu        A937           0              (no arguments)
 * 1) Double click on ResEdit (i.e., run ResEdit).
 * 2) Double click on QuickBASIC (either Binary or Decimal).
 * 3) Scroll down to the &quot;MBTS&quot; resource.
 * 4) Double click on &quot;MBTS&quot;.
 * 5) Double click on 'MBTS &quot;ToolBox Args&quot; ID = 1'.
 * 6) This will bring up a window containing the initial listing of the 29 predefined procedures.
 * 7) Click once on the five (5) asterisks (*****).
 * 8) Select New from the File menu (or press COMMAND+N).
 * 9) A new trap number and call type should become available.
 * 10) Click on the trap number box and enter the first trap number you want to define (A933). This number must be entered in the Pascal format for Hex numbers (that is, $A933).
 * 11) Click on the call type box and enter a value for the call type needed. In this example, 0 would be entered.
 * 12) Click on the five (5) dashes (-).
 * 13) From the File menu, select New (or press COMMAND+N).
 * 14) Click on the argument type box and enter the argument type for the first parameter. In this example, enter 2.
 * 15) If more argument types are needed, go back and repeat steps 11 through 13 for each parameter being passed. In this example, you would repeat the process one more time and enter a 4.
 * 16) One ToolBox call has been added so far to the &quot;MBTS&quot; resource. If you need to add more routines to the &quot;MBTS&quot; resource, as in the example, you would need to repeat steps 6 through 14 three more times.
 * 17) Once you are completed adding routines, you can close this window.
 * 18) Close the next window.
 * 19) Close the next window.
 * 20) Answer Yes to the dialog box if you would like your changes to be saved, or No if not.
 * 21) From the File menu, choose Quit to end ResEdit.
 * 22) Now all of these routines entered can be called from within this version of QuickBASIC without having to add the &quot;Q&quot; on the ToolBox call.

When running code that makes calls to these newly added routines and errors result, you can check your entries and edit them by using the same process and go under ResEdit and bring up QuickBASIC again.

The example program could now be coded as follows: MenuID% = 100 MH& = 0 NewTrap& = &HA931 AppendTrap& = &HA933 InsertTrap& = &HA935 DrawTrap& = &HA937 ToolBox &quot;i&quot; ToolBox &quot;L&quot;, NewTrap&,(MenuID%),(&quot;OPTIONS&quot;),MH& ToolBox &quot;P&quot;, AppendTrap&,(MH&),(&quot;Option 1;Option 2&quot;) ToolBox &quot;P&quot;, InsertTrap&,(MH&),(0) ToolBox &quot;P&quot;, DrawTrap& WHILE MOUSE(0) <> 1 : WEND END

Additional query words: MQuickB

Keywords: KB48057

-

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

© Microsoft Corporation. All rights reserved.