Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
PROGRAM ORGANIZATION
mikroBasic PRO for AVR imposes strict program organization. Below you can find
models for writing legible and organized source files. For more information on file
inclusion and scope, refer to Modules and to Scope and Visibility.
Organization of Main Module
Basically, a main source file has two sections: declaration and program body. Dec-
larations should be in their proper place in the code, organized in an orderly man-
ner. Otherwise, the compiler may not be able to comprehend the program correctly.
When writing code, follow the model presented below. The main module should look
like this:
program <program name>
include <include other modules>
'********************************************************
'* Declarations (globals):
'********************************************************
' symbols declarations
symbol ...
' constants declarations
const ...
' structures declarations
structure ...
' variables declarations
dim
Name[, Name2...] 
as
[^]type [absolute 0x123] [
external]
[volatile] [
register] [sfr]
' procedures declarations
sub procedure procedure_name(...)
<local declarations>
...
end sub
' functions declarations
sub function function_name(...) as return_type
<local declarations>
...
end sub
'********************************************************
'* Program body:
'********************************************************
main:
' write your code here
end.
120
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5