11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler5.31. INCLUDESyntax :Overview :INCLUDE “Filename”Include another file at the current point in the compilation. All the linesin the new file are compiled as if they were in the current file at thepoint of the INCLUDE command.A Common use for the include command is shown in the examplebelow. Here a small master document is used to include a number ofsmaller library files which are all compiled together to make the overallprogram.Operators :Example :Notes :Filename is any valid <strong>PICBASIC</strong> <strong>PLUS</strong> file.‘ Main Program INCLUDES sub filesINCLUDE “STARTCODE.BAS”INCLUDE “MAINCODE.BAS”INCLUDE “ENDCODE.BAS”The file to be included into the BASIC listing may be in one of threeplaces on the hard drive.1… Within the INC folder of the compiler’s current directory.2… Within the Compiler’s current directory.3… Within the BASIC program’s directory.The list above also shows the order in which they are searched for.Using INCLUDE files to tidy up your code.If the include file contains assembler subroutines then it must alwaysbe placed at the beginning of the program. This allows the subroutine/sto be placed within the first bank of memory (0..2048), thusavoiding any bank boundary errors. Placing the include file at the beginningof the program also allows all of the variables used by the routinesheld within it to be pre-declared. This again makes for a tidierprogram, as a long list of variables is not present in the main program.There are some considerations that must be taken into account whenwriting code for an include file, these are: -1). Always jump over the subroutines.When the include file is placed at the top of the program this is thefirst place that the compiler starts, therefore, it will run the subroutine/sfirst and the RETURN command will be pointing to a randomplace within the code. To overcome this, place a GOTO statementjust before the subroutine starts.67Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!