"Illegal Function Call" CHAINing to Stand Alone, /Fpa, or /Fs (61483)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1

This article was previously published under Q61483

SUMMARY

Attempting to CHAIN from an EXE that requires a run-time module to a stand-alone EXE causes the run-time error "Illegal Function Call" on the CHAIN statement.

This error message does not occur when CHAINing in the reverse direction (from a stand-alone EXE to an EXE that requires a run-time module), or when CHAINing between identical EXE types (both stand alone, or both run time), or when using the RUN statement instead of CHAIN.

"Illegal Function Call" also occurs when CHAINing from an EXE that requires a run-time module to an EXE compiled with a different math package (/Fpa versus /Fpi; found only in BC.EXE 6.00, 6.00b, 7.00, or 7.10) or compiled with a different string option (/Fs far strings versus near strings; found only in Microsoft Basic Professional Development System (PDS) version 7.00 or 7.10).

This information applies to Microsoft QuickBasic versions 4.00, 4.00b, and 4.50 for MS-DOS; to Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2; and to Microsoft Basic PDS versions 7.00 and 7.10 for MS-DOS and MS OS/2.

This information also applies to Visual Basic for MS-DOS version 1.00.

MORE INFORMATION

When transferring control to an EXE with a different run-time module, the RUN statement is the preferred method. RUN makes no attempt to preserve any values on the transfer, whereas CHAIN tries to maintain COMMON variables. The CHAIN statement should be used only when transferring control to another Basic program that uses the same Basic run-time library as the one being CHAINed from.

Code Example

The following code example produces an "Illegal Function Call" on the CHAIN statement when the two programs are compiled as indicated:
   'A.BAS
   'Compile and link lines:
   '   BC A;
   '   LINK A;
   CHAIN "B"         'RUN does not cause the error
   END

   'B.BAS
   'Compile and link lines:
   '   BC /o B;
   '   LINK B;
   PRINT "In Program B"
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB61483