$main - identify main module


rem $main


The $main metacommand appears in the module as part of a remark, either after the rem keyword or after a single quote.  This metacommand may not appear after an executable statement.  The appearance of this metacommand in a module (file) implies that it is the "main" module. 

The main module is the module where the execution of the program begins.  Exactly one module of a program is designated the main module. 


The program, "main.b":
	rem $main
	print "you are here"
even if compiled with the "-M" switch:
	$ basic -M main.b
will compile and load to an executable on its own because it is a main module. 


When the compiler is invoked, by default, the first module specified on the command line is assumed to be the main module.  This default can be overridden and no module assumed to be the main module if the compiler is invoked with the "-M" switch (see basic(1) in the Supplemental Documentation section of this manual).  The "-M" switch is preferred in the UNIX environment with utilities such as "make" where assumptions about the position of filenames on the command line are unconventional.  Dispensing with the positional dependence, the method of identifying the main module with the $main metacommand (and the invocation of the compiler with the "-M" switch) has been invented and is encouraged by Basmark.  Note that the old method of listing the main module first on the command line without any special switches remains supported. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber