98
The second method of setting the Heap Limit is to specify the desired size of the heap using the directive
Option HeapSize in your Main module or by using the compiler option -heap-size. The Heap Limit
is set by subtracting the specified value from the address one past the end of RAM. For devices that
have external RAM, the end of RAM is determined at startup. If you have external RAM, you may specify
that all of the external RAM should be used for the heap by specifying the heap size using the special
values 65535 or &HFFFF.
The final method for setting the Heap Limit is to specify an absolute address using the directive Option
HeapLimit in your Main module or by using the compiler option -heap-limit. This method is
recommended for use only by advanced programmers who understand completely how memory is
allocated in a native ZBasic application.
4.7 Creating and Using Object Libraries
It is often useful to create a library of code elements from which the essential elements are drawn when
building an application. Such libraries can then be easily reused in several applications or distributed to
other ZBasic users for use in building their applications. The ZBasic compiler supports the creation of
object libraries only for native mode devices.
To instruct the ZBasic compiler to build a library instead of building a downloadable file as it normally
does, add the option -create-library to your project file. If no filename is specified with that option,
the library name will be same as the project name but with the extension .a. The compiler will create an
additional file containing ZBasic declarations for all of the public elements in the library; this file with have
the same name as the library but with the extension .inc. It is important to note that none of the ZBasic
files compiled into the library should have a public subroutine named Main().
To use the library in a ZBasic application, it is only necessary to add the name of the declarations file to
that applications project file or, alternately, to include the declarations file in one of your modules (e.g. the
Main() module) using the #include directive. Generally, the declarations file and the library file should
be kept in the same directory. The declarations file contains a directive to tell the compiler the name of
the corresponding library file thats why it doesnt need to be explicitly mentioned.
If you create library files to distribute to others, you only need to supply the declarations file and the library
file. The source code for the library neednt be distributed if youd like to keep it proprietary.