Microsoft KB Archive/48057

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 13:14, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


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 "MBTS" 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, "Argument Checking" on pages 502 to 503 of the "Microsoft QuickBASIC for Apple Macintosh: Language Reference" manual.

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

MORE INFORMATION

The "MBTS" 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 "MBTS" resource stored in both the binary and decimal versions of QuickBASIC, you can avoid the necessity of adding a "Q" in the Toolbox call argument.

As mentioned on page 499, you normally add a"Q" to the calltype$ string of the ToolBox statement to skip argument checking and call routines not listed in QuickBASIC's "MBTS" resource. If you know exactly what parameters to pass, using "Q" is not a problem; however, one danger of using "Q" 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 "Q" 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 "Q".

   MenuID% = 100
   MH& = 0
   NewTrap& = &HA931
   AppendTrap& = &HA933
   InsertTrap& = &HA935
   DrawTrap& = &HA937
   ToolBox "i"
   ToolBox "LQ", NewTrap&,(MenuID%),("OPTIONS"),MH&
   ToolBox "PQ", AppendTrap&,(MH&),("Option 1;Option 2")
   ToolBox "PQ", InsertTrap&,(MH&),(0)
   ToolBox "PQ", 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 "MBTS" resource.
  4. Double click on "MBTS".
  5. Double click on 'MBTS "ToolBox Args" 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 "MBTS" resource. If you need to add more routines to the "MBTS" 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 "Q" 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 "i"
   ToolBox "L", NewTrap&,(MenuID%),("OPTIONS"),MH&
   ToolBox "P", AppendTrap&,(MH&),("Option 1;Option 2")
   ToolBox "P", InsertTrap&,(MH&),(0)
   ToolBox "P", DrawTrap&
   WHILE MOUSE(0) <> 1 : WEND
   END
                


Additional query words: MQuickB

Keywords: KB48057