Source Files (.bas)

Text files read by FreeBASIC and compiled into executable code.

A source file is a text file that contains FreeBASIC language statements. A program might be made from just one source file or possibly hundreds. Source files are read by the compiler and compiled into object code. Object code is then linked to create an executable or can be stored for later use as a library.

FreeBASIC by default, automatically takes care of compiling sources and linking object modules in to executables, so normally it is possible to make an executable program by just passing the names of the source files on the fbc command line. For example, assuming we had three source files that together made a program, we could create an executable for the program by running fbc, the FreeBASIC compiler on a command line as follows:
fbc myprog.bas tools.bas funcs.bas

Unicode support
Implicit main()
Some languages require a special main() procedure be defined as an entry point to the program which define the first statements that will be executed when the program starts. FreeBASIC allows executable statements in module level code and normally the first source file passed to fbc on the command line will be used as the "main" module. The main module can be explicitly names by passing -m filename on the command line, where filename is the name of the main module without the .bas extension.
    '' sample.bas
    Declare Sub ShowHelp()

    '' This next line is the first executable statement in the program
    If Command(1) = "" Then
        End 0
    End If 

    Sub ShowHelp()
        Print "no options specified."  
    End Sub

Header Files
A header file is a special kind of source file that typically only contains declarations and has a .bi extension. See Header Files (.bi).

See also:
Back to Programmer's Guide
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode