The Variable Fct

 

If you want the users or other DLL modules to be able to access static variables of your module, you can do this with the "Variable" mechanism.

 

To do this, you must first register your variables.  When the user, or another module, need your variables, sliceOmatic will call your Variable_Get function to retrieve a pointer to the variable.

 

 

Variable_Register

This function is used to register your variables

 

 

Variable_Get

This function is used to get a pointer to one of the registered variables.

 

 

Your variable will then be visible by the other modules. It can be listed with the sliceOmatic command:

 

Variable: List

 

And they can be used and/or modified directly from the command line.

 

$DEMO_VAR_FLOAT = 2.3

echo: $DEMO_VAR_FLOAT

2.3

 

 

Also, other modules can get the value of the variables with "Fct_Variable_Value" and a pointer to the variables with "Fct_Variable_Get"

 

Example 1:

 

// --- get a pointer to the frame under the cursor ---

SliceO_Frame *Frame_Ovr = (SliceO_Frame *) Fct_Variable_Value( "$FRAME_OVR" ) ;

 

The variable "Frame_Ovr" will contain a pointer of the frame currently under the cursor.  If the cursor is not over a frame, the variable will be NULL

 

Example 2:

 

// --- get a pointer to the array of TAG_Lock flags ---

unsigned int  TAG_Nb ;

unsigned char * TAG_Lock = (unsigned char *) Fct_Variable_Value( "$TAG_LOCK", &TAG_Nb ) ;

 

The variable "TAG_Lock" will contain a pointer to an array of "TAG_Nb" unsigned char values.  Each of these is the TAG_Lock flag for one of the TAGs

 

Example 3:

 

// --- Make the TAG_1 the current tag ---

int (*update)(void) = NULL ;

unsigned short *TAG_Cur = (unsigned short *) Fct_Variable_Get( "$TAG_CUR", NULL, NULL, &update ) ;

if ( TAG_Cur ) {

          *TAG_Cur = 1 ;

          if ( update )

                    update() ;

}

 

If it is not null, the "update" variable will contain a pointer to a function that will update all the necessary modules once you modified a variable.

 

 

Note:

 

By convention, variable names are upper case, do not contain spaces and start with "$".  (ex: $DB_ROOT_PT)

 

Note:

 

Even if you do not register your variables with sliceOmatic, it might be a good idea to declare all your static variables in this file.