User manual

mikroPascal PRO for PIC32
MikroElektronika
187
Program Organization
mikroPascal PRO for PIC32 imposes strict program organization. Below you can nd models for writing legible and
organized source les. For more information on le inclusion and scope, refer to Units and Scope and Visibility.
Organization of Main Unit
Basically, the main source le has two sections: declaration and program body. Declarations should be in their proper
place in the code, organized in an orderly manner. Otherwise, the compiler may not be able to comprehend the program
correctly.
When writing code, follow the model presented below. The main unit should look like this:
program { program name }
uses { include other units }
//********************************************************
//* Declarations (globals):
//********************************************************
{ constants declarations }
const ...
{ types declarations }
type ...
{ variables declarations }
var Name[, Name2...] : [^]type; [absolute 0x123;] [external;] [volatile;] [register;]
[sfr;]
{ labels declarations }
label ...
{ procedures declarations }
procedure procedure_name(parameter_list);
{ local declarations }
begin
...
end;
{ functions declarations }
function function_name(parameter_list) : return_type;
{ local declarations }
begin
...
end;
//********************************************************
//* Program body:
//********************************************************
begin
{ write your code here }
end.