Microsoft KB Archive/20538

= "System Error" with Inadvertent Implied CALL; B=2: B ; C-D=E =

Article ID: 20538

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 1.0
 * Microsoft QuickBASIC 1.0b
 * Microsoft QuickBASIC 1.0b
 * Microsoft BASIC Interpreter 2.0
 * Microsoft BASIC Interpreter 2.1 for Macintosh
 * Microsoft BASIC Interpreter 3.0 for Macintosh
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q20538



SUMMARY
This information applies to Microsoft QuickBASIC Versions 1.00, 1.00a, 1.00b, Microsoft BASIC Compiler Version 1.00, and Microsoft BASIC Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

The following "valid" BASIC statement can cause a System Error: B=2 : B   ' This is the same as B=2 : CALL B Because B has not been defined as a subprogram, BASIC assumes that you are calling the machine-language routine at the address (2) contained in B. Because you have not yet placed a proper machine-language routine at this address, you usually will get a System Error and must reboot. This is an example of an "implied CALL", a special CALL syntax that does not require an explicit CALL statement. For more information about implied CALLs, refer to the CALL statement documentation.



MORE INFORMATION
Here is another example of an implied CALL that hangs the system: C - D = E You might type a statement like the above by mistake, but this perfectly legal syntax tells BASIC to use an equal sign (=) as a relational operator instead of the assignment operator. When C, D, and E are zero (by default), then the above expression D=E returns a value of true (-1). C minus -1 equals +1. The value of the expression C-D=E is thus +1. The one-line program C-D=E will therefore make an implied CALL to the machine code routine at the address +1, which is not a valid routine; at this point, the computer hangs or you get a System Error. (For more information, please look up "relational operators" in the index of the "Microsoft BASIC Compiler Version 6.00 for MS OS/2 and MS-DOS: BASIC Language Reference.")

An inadvertent implicit call is easy to do by mistake when debugging from the interpreter's COMMAND window. If you simply type a variable name in the COMMAND window and hit the RETURN key, you will probably hang because this is a syntactically legal implicit CALL, and the number stored in the variable is almost certainly not a valid address of executable machine code.

This process also may occur if the machine code array moves between the time you take its address and make the CALL. For this reason, the "Microsoft BASIC Interpreter for Apple Macintosh" Versions 2.x and 3.00 manual warns you to always take the address IMMEDIATELY before the call, as in the following program fragment: code# = VARPTR( MyCode%(0) ) 'get address of my machine code array code# arg1%,arg2%  'call my routine

Additional query words: BasicCom MQuickB

Keywords: KB20538

-

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

© Microsoft Corporation. All rights reserved.