AKD BASIC User Guide | 3 AKDBASICLanguage
3 AKDBASICLanguage
This chapter describes the overall structure of an AKD BASIC program and the elements of the
AKD BASIC language. Topics covered are:
l scope
l program structure
l setup parameters
l global variables, constants and aliases
l ‘main’ program, subroutines, functions and interrupt handlers
l language description
l lexical conventions
l identifiers
l data types
l constants
l statements
l built-in functions
l parameters
l expressions
l function invocation
l $include
l arrays and parameter lists
l optimizations
3.1 AKD BASIC Program Structure
3.1.1 Local Variables
The notion of ‘scope’ is a key concept in AKD BASIC programs. By ‘scope’, we mean those
parts of the program in which a particular name is ‘visible’. There are two levels of scope in
AKD BASIC — global and local. Variables (and constant definitions, aliases, etc.) defined
inside a ‘main’ definition, or a subroutine, function, or interrupt handler definition, are considered
to be ‘local’ in scope (visible only within that function).
3.1.2 Global Variables
All other definitions (those occurring outside functions) are considered ‘global’ in scope (visible
inside main, and inside any subroutine, function, or interrupt handler). For example, consider
the following simple AKD BASIC program:
'-------------- Define (dim) Global Variables -
-------
dim i as integer
'-------------- Main Program ------------------
-------
Main
dim i as integer
for i = 1 to 10
print "the cube of "; i; "is "; cube(i)
call increment
next i
End Main
Kollmorgenâ„¢ | March 30, 2012 20