BASIC Moves Development Studio
06/2005
Danaher Motion
40 Rev
E
M-SS-005-03l
2.4.1. Global
Libraries
Global libraries are library files (.LIB), which, instead of being loaded from
either the terminal or another task, are loaded from the configuration file
(Config.Prg). Another option is loading from terminal, using
LOADGLOBAL
.
PUBLIC subroutines and functions defined in such libraries can be called
from everywhere (i.e., terminal and other tasks), without first being imported
by the calling task.
IMPORT
cannot be applied to global libraries.
LOAD
GlobLib.lib ‘ In Config.Prg
LOADGLOBAL
GlobLib.lib ‘ In terminal
IMPORT
GlobLib.lib
Æ
Error ‘ In task or library
The syntax for calling a global library’s subroutine or function from either the
terminal or task is the same as the syntax for calling a subroutine or
function of a regular (imported) library. Because of the wide recognition
scope of global, public functions and subroutines, the names of such
subroutines and functions cannot be used for another function or
subroutine, variable, motion element, etc. As in regular libraries,
subroutines and functions declared without the
PUBLIC
keyword can only
be used inside the scope of the library.
A global library cannot be unloaded if there are task files (.PRG) loaded in
memory. To unload a global library, all .Prg files must first be unloaded. If a
global library file is unloaded and then reloaded from either the terminal or a
task, it becomes a regular library, which must be imported before use.
2. 5
C-F
UNCTIONS
The MC offers users an outstanding option to incorporate applications written
in C or C++ into an MC-Basic task.You can write your algorithm in C/C++,
compile it with a GNU compiler, download it into a target program and call
the code from a program written in MC-Basic or directly from the command
line.
The parameters can be passed by value as well as by reference. This
function returns a value that can be processed by an MC-Basic application.
MC-BASIC provides a facility to load a user object-file into the RAM of the
MC. This file is relocatable and must include information about global
symbols for the MC to find the C-function. The object module may consist of
any number of functions. The only restriction is RAM limit.
2.5.1. Object
Files
Object files (extension “.o”), contain compiled C-programs and are stored in
the Flash disk. You can
SEND
object files to the controller, load files into
RAM with
OLOAD
and unload them with
OUNLOAD
. If
OLOAD/OUNLOAD
fails for any reason, details are found in the OLOAD.ERR file.