ZBasic Language Reference
17
ZX Microcontroller Family
Option Overload
Option Overload
Default: none
This option enables the definition of subroutine/function overloads. If used, it must appear for the first
time in the first module compiled. If it does appear in the first module compiled then its presence in other
modules is silently ignored. Note that this option is redundant if Option Objects is present.
Example
Option Objects
Option Library
Option Library "<object-library-filename>"
Default: none
This option, which can only be used for native mode devices, specifies the name of an object library that
should be linked in when the executable is built. Typically, this directive will appear in a declarations file
that identifies the public entities contained in the library. If the specified filename does not have a path
prefix, it is assumed that the specified name is relative to the directory of the module containing the
directive.
This option may be used in multiple modules as needed.
Example
Option Library "mylib.a"
2.3.2 The Definitions Section
The definitions section of a ZBasic program may contain constant definitions, variable definitions,
subroutine definitions and function definitions. There may be any number of each of these types of
definitions and the definitions may occur in any order. It is a common practice, however, to place
constant and variable definitions at the top of the definitions section followed by subroutine and function
definitions. On the other hand, some programmers prefer to define the constants and variables closer to
the routine or routines that use them.
BasicX Compatibility Note
In BasicX mode, all variables and constants must be defined
before the first subroutine or function in a module.
Each of these program items may be defined to be Public or Private. A public item is visible to other
modules and may be referenced in the definitions contained in other modules. A private item is visible
only within the module in which it is defined. Generally speaking, unless there is a specific need for an
item to be public, it should be private. If you make something private and later decide that you need to
reference it in another module, it is a simple matter to change the definition from private to public.
Defining Constants
It is often convenient to define constants that can be used in other parts of the program. Doing so
generally helps clarify the purpose of the value, assuming a reasonably descriptive name is chosen, and
also facilitates easier maintenance and modification of the program.