User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
making it simple...
Procedures and functions, collectively referred to as routines, are self-contained
statement blocks that can be called from different locations in a program. Function
is a routine that returns a value when it is executed. Procedure is a routine that
does not return a value.
Once these routines have been defined, you can call them once or multiple times.
Procedure is called upon to perform a certain task, while function is called to com-
pute a certain value. Function calls, because they return a value, can be used as
expressions in assignments and operations.
Procedure declaration has the form:
sub procedure procedureName(parameterList)
localDeclarations
statements
end sub
where procedureName is any valid identifier, statements is a sequence of state-
ments that are executed upon the calling the procedure, and (parameterList) and
localDeclarations are optional declaration of variables and/or constants.
sub procedure pr1_procedure(dim par1 as byte, dim par2 as byte,
dim byref vp1 as byte, dim byref vp2 as byte)
dim locS as byte
par1 = locS + par1 + par2
vp1 = par1 or par2
vp2 = locS xor par1
end sub
par1 and par2 are passed to the procedure by the value, but variables marked by
keyword
byref are passed by the address.
50
page
PROCEDURES AND FUNCTIONS
Procedures