 
  
  
  
 
This module provides support for defining global variables in such a
way that there is a lookup table of global variable names.  This table
can be used to provide reading of global variables from files at
runtime, or to allow the user to query and modify global variable
values during program execution.  In order to use this facility, the
programmer must have (either directly or indirectly)
#include  <globals.h>
in every program file that refers to a global variable.  The
global variables must be defined in a file called
global_variables.h which has the following form:
START_GLOBALS
    DEF_GLOBAL(        Mine_1, BOOLEAN,  TRUE )
    DEF_GLOBAL(        Mine_2, int,      3 )
    DEF_GLOBAL(        Mine_3, Real,     2.5 )
    DEF_GLOBAL(        Mine_4, Colour,   RED )
    DEF_GLOBAL5(       Mine_5, Surfprop,
                       0.3, 0.6, 0.6, 40.0, 1.0 )
    DEF_GLOBAL3(       Mine_6, Vector,   1.0, 0.0, 0.0 )
    DEF_GLOBAL3(       Mine_7, Point,    2.0, 2.0, 2.0 )
    DEF_GLOBAL_STRING( Mine_8, "Initial value" )
END_GLOBALS
The first argument of each of these macros is the name of the global
variable.  The second argument is the type of the global variable.
Note that only the types in the previous example are supported.  The
final argument or arguments are the initial values of the global
variable.
Finally, one needs to create the lookup table in one program file,
usually the main program file, as follows:
#define  GLOBALS_LOOKUP_NAME  my_globals
#include  <globals.h>
which creates a global variable lookup table called
my_globals (any name may be chosen for this table).
Relevant functions for global variables are:
public  Status  input_globals_file(
    int             n_globals_lookup,
    global_struct   globals_lookup[],
    char            filename[] )
    if( input_globals_file( SIZEOF_STATIC_ARRAY(my_globals),
           my_globals, filename ) != OK )
    {
        print( "Error reading globals file.\n" );
    }
public  Status  get_global_variable(
    int              n_globals_lookup,
    global_struct    globals_lookup[],
    char             variable_name[],
    char             value[] )
    if( get_global_variable( SIZEOF_STATIC_ARRAY(my_globals),
            my_globals, "my_variable", value_string ) == OK )
    {
        print( "Value is: %s\n", value_string );
    }
is equivalent to:
    print( "Value is: %d\n", my_variable );
public  Status  set_global_variable(
    int              n_globals_lookup,
    global_struct    globals_lookup[],
    char             variable_name[],
    char             value_to_set[] )
    if( set_global_variable( SIZEOF_STATIC_ARRAY(my_globals),
            my_globals, "my_variable", "45" ) != OK )
    {
        print( "Error setting variable.\n" );
    }
is equivalent to
    my_variable = 45;
public  Status  set_or_get_global_variable(
    int              n_globals_lookup,
    global_struct    globals_lookup[],
    char             input_str[],
    char             variable_name[],
    char             value_string[] )
 
  
  
 