Microsoft KB Archive/34291

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


Using Same Source to CHAIN When Both Interpreted and Compiled

Article ID: 34291

Article Last Modified on 1/8/2003



APPLIES TO

  • Microsoft QuickBasic Compiler for Macintosh 1.0



This article was previously published under Q34291

SUMMARY

The following information applies to the Microsoft QuickBASIC Compiler Version 1.00 for the Apple Macintosh.

It is possible to write a QuickBASIC program that CHAINs both in the interpreter environment and in a compiled application without changes to the source file. The first method uses the $IGNORE metacommand, while the second uses the SYSTEM(4) function. The REM $IGNORE ON metacommand instructs the compiler to ignore the following statements until a REM $IGNORE OFF is encountered. The SYSTEM(4) function returns 1 in a compiled program and 0 in an interpreted program.

MORE INFORMATION

Let us assume that we have a program "proga" which CHAINs to "progb". The following is the listing for "progb":

   PRINT "inside progb"
   END
                

When you compile the "progb" source file, the compiler names the compiled application "progb apl" by default.

The following is the listing for "proga" using the first (REM $IGNORE ON/OFF) method:

  CLS
  PRINT "inside proga"
  ext$ = " Apl"
  nxtprog$ = "progb"
  REM $IGNORE ON
  ext$ = ""
  REM $IGNORE OFF
  nxtprog$ = nxtprog$ + ext$
  CHAIN nxtprog$
                

The following is the listing for "proga" using the second [i.e., SYSTEM(4)] method:

  CLS
  PRINT "inside proga"
  ext$ = " Apl"   ' Compiler appends " Apl" to application names.
  nxtprog$ = "progb"
  ' When SYSTEM(4) returns 0, we're inside environment:
  IF SYSTEM(4) = 0 THEN ext$ = ""
  nxtprog$ = nxtprog$ + ext$
  CHAIN nxtprog$
                


Additional query words: MQuickB

Keywords: KB34291