Global code

Sometimes it is necessary to provide functions that occur in multiple objects, for example in multiple
calculator objects. Now it is not very nice to define the same function again and again, it is possible to define global functions or variables that can be accessed in all objects that use the shared library concept, for example calculator objects and fitter objects etc. Multiple global functions are combined in global modules. Each global module is compiled to a shared library and loaded before all object's shared libraries.
Fig. 1: List of global modules

Fig. 2: Global module code entry

To create a global module, choose "Global code..." in the file menu. The list of global modules is displayed, as given in Fig. 1. When pressing the Add button, a new global module is created and a dialog is displayed as given in Fig. 2. All functions and variables defined in global modules can be accessed from code in other objects or from code in other global modules. For example, if you define a global function

void hugo() { printf("Hello!"); } you can call this function from for example a calculator object in the following way: extern hugo(); extern "C" bool run() { hugo(); return true; }; This calls the global function hugo() out of calculator's run() function. All you have to do is to declare the global function external using the extern keyword.

Global variables can be used by providing global "set" and "get" functions which return and set a variable defined within a global module. Directly accessing global variables is not supported.

Vimms user manual
F. Hitzel, 2003