Datasheet
Programming PIC Microcontrollers in BASIC - mikroElektronika
locS = par1 * (par2 + 1)
Result = locS
end sub
As functions return values, function calls are technically expressions. For example, if you have defined a function
called Calc, which collects two integer arguments and returns an integer, then the function call Calc(24, 47) is
an integer expression. If I and J are integer variables, then I + Calc(J, 8) is also an integer expression.
2.13 Modules
Large programs can be divided into modules which allow easier maintenance of code. Each module is an actual file,
which can be compiled separately; compiled modules are linked to create an application. Note that each source file
must end with keyword end followed by a dot.
Modules allow you to:
1. Break large code into segments that can be edited separately,
2. Create libraries that can be used in different programs,
3. Distribute libraries to other developers without disclosing the source code.
In mikroBasic IDE, all source code including the main program is stored in .pbas files. Each project consists of a
single project file, and one or more module files. To build a project, compiler needs either a source file or a compiled
file for each module.
Every BASIC application has one main module file and any number of additional module files. All source files have
same extension (pbas). Main file is identified by keyword program at the beginning, while other files have
keyword module instead. If you want to include a module, add the keyword include followed by a quoted name
of the file.
For example:
program test_project
include "math2.pbas"
dim tA as word
dim tB as word
main:
tA = sqrt(tb)
end.
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/02.htm (11 sur 12)05/11/2004 02:12:53