Run variablesAdding application specific variablesOrdinary Tcl Variablesconst "variables"

const "variables"

Const variables are variables that can only be modified from within the C++ code. They are intended to be used by C++ code to provide status information to scripts running monitoring tasks. You can also use const variables to provide useful constants for your scripts.

Suppose, for example, your experiment responds to several trigger types. You might create const variables that maintain the number of triggers of each type that have been processed for each run.

Const variables are derived from ordinary tcl variables (CTCLVariable). In fact, as far as the interpreter is concerned. a const is just an ordinary tcl variable that has a trace set on writes that undoes any modifications. const variables can, therefore be used by scripts as if they were read-only variables. Writing a const from a script will produce an error message. For example:

	     %  const testing 5
	     %  set testing 6
	     can't set "testing": Attempt to modify constant testing
	     %
	

To create a const status variable from within your C++ code you must:

You can create a const variable and register it with the const command in e.g. SetupRunVariables as shown below:

	    ...
	       CTCLInterpreter* pInterp           = rStartup.getInterpreter();
	       CConstVariable* pSinglesCounter = 
			new CConstVariable(pInterp, string("singles"), string("0"));
	       rCore.getConstVariables()->Enter(pSinglesCounter);
	    ...
	 

You can use either of the mechanisms described in: Ordinary Tcl variables to access const variables once they have been created. Note that run variables are automatically registered when created.


Report documentation errors to Ron Fox (fox@nscl.msu.edu)or NSCL's Bugzilla page

Run variablesAdding application specific variablesOrdinary Tcl Variablesconst "variables"