User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
This means that the procedure call
pr1_procedure(tA, tB, tC, tD)
passes tA and tB by the value: it first creates par1 = tA and par2 = tB, then manip-
ulates par1 and par2 so that tA and tB remain unchanged;
passes tC and tD by the address: whatever changes are made upon vp1 and vp2
are also made upon tC and tD.
Note that a procedure without parameters can be substituted by label which marks
the beginning of “procedure” and keyword
return that marks the end of “proce-
dure”. To call such subroutine, use the keyword
gosub. These subroutines must be
placed between the label main: and the end of the source file.
main:
if PORTC.1 = 1 then
gosub TogglePortb
end if
...
' some code
TogglePortb:
' routine
portb = not portb
return
end.
Function declaration is similar to procedure declaration, except it has a specified
return type and a return value. Function declaration has the form:
sub function functionName(parameterList) as returnType
localDeclarations
statements
end sub
where functionName is any valid identifier, returnType is any simple type, state-
ments is a sequence of statements to be executed upon calling the function, and
(parameterList) and localDeclarations are optional declarations of variables
and/or constants.
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
51
page
Functions