Microsoft KB Archive/94790

= PRB: Illegal function call or Bad file w/ CHAIN and Overlays =

PSS ID Number: 94790

Article Last Modified on 1/9/2003

-

The information in this article applies to:


 * Microsoft Visual Basic for MS-DOS 1.0

-



This article was previously published under Q94790



SYMPTOMS
When using the Basic CHAIN command to pass control of your program to another Basic program, you can get the &quot;Illegal function call&quot; or &quot;Bad file mode&quot; error if the calling program contains overlays.

You get the &quot;Illegal function call&quot; error if you compiled your program to use a run-time module and the &quot;Bad file mode&quot; error if you compiled it for stand-alone (BC /O).



STATUS
This behavior is by design. The limitation is documented in the &quot;Microsoft Visual Basic Professional Features&quot; manual on page 34, labeled &quot;Warning.&quot;



Steps to Reproduce Problem
  Create two Basic (.BAS) modules named MOD1.BAS and MOD1B.BAS that contain the following code: MOD1.BAS:

Declare Sub sub1 Cls Print &quot;In mod1&quot; Call sub1

MOD1B.BAS:

Sub sub1 Print &quot;In Sub1 of mod1&quot; Chain &quot;mod2&quot; End Sub   Compile these using the Visual Basic for MS-DOS compiler (BC.EXE) in the following manner: BC MOD1.BAS; BC MOD1B.BAS;   Create two more Basic (.BAS) modules named MOD2.BAS and MOD2B.BAS that contain the following code: MOD2.BAS:

Declare Sub sub1 Print &quot;In mod2&quot; Call sub1 Print &quot;End of mod2&quot; END

MOD2B.BAS:

Sub sub1 Print &quot;In sub1 of mod2&quot; End Sub   Compile these in the same manner as follows: BC MOD2.BAS; BC MOD2B.BAS;   LINK the programs with the following commands: LINK MOD1+(MOD1B); LINK MOD2+MOD2B;  Now run the program by typing MOD1.EXE and pressing ENTER at the MS-DOS prompt.</li></ol>

At this point, you'll see an &quot;Illegal function call&quot; message. To see the &quot;Bad file mode&quot; error message, use the /O (stand-alone) option when compiling with the BC.EXE compiler.

Additional query words: VBmsdos 1.00 overlay

Keywords: kbprb KB94790

Technology: kbAudDeveloper kbVB100DOS kbVBSearch kbZNotKeyword3

-

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

© 2004 Microsoft Corporation. All rights reserved.