{{fbdoc item="title" value="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
##
{{fbdoc item="section" value="Unicode support"}}
	- Besides ASCII files with Unicode escape sequences (\u), FreeBASIC can parse UTF-8, UTF-16LE, UTF-16BE, UTF-32LE and UTF-32BE source (.bas) or header (.bi) files, they can be freely mixed with other sources/headers in the same project (also with other ASCII files).

	- Literal strings can be typed in the original non-Latin alphabet, just use a text-editor that supports one of the Unicode formats listed above.

{{fbdoc item="section" value="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.
{{fbdoc item="filename" value="examples/manual/proguide/sourcefiles.bas"}}%%(freebasic)
	'' sample.bas
	declare sub ShowHelp()

	'' This next line is the first executable statement in the program
	if command(1) = "" then
		ShowHelp
		end 0
	end if	

	sub ShowHelp()
		print "no options specified."	
	end sub
%%

{{fbdoc item="section" value="Header Files"}}
	A header file is a special kind of source file that typically only contains declarations and has a ##.bi## extension. See [[ProPgHeaderFiles Header Files (.bi)]].

{{fbdoc item="see"}}
	- [[CompilerCmdLine fbc command-line]]
	- [[ProPgHeaderFiles Header Files (.bi)]]

{{fbdoc item="back" value="CatPgProgrammer|Programmer's Guide"}}