Index: trunk/SophyaLib/SysTools/cexpre.cc
===================================================================
--- trunk/SophyaLib/SysTools/cexpre.cc	(revision 4034)
+++ trunk/SophyaLib/SysTools/cexpre.cc	(revision 4063)
@@ -45,15 +45,18 @@
 class CE_NumberExp : public CExprBase {
 public:
-  CE_NumberExp(double v) { _val = v; }
+  CE_NumberExp(double v) { _val = v; _pval=&_val; }
+  CE_NumberExp(double* pv) { _pval=pv; _val = *_pval; }
   CE_NumberExp(string const & s);
   virtual ~CE_NumberExp() {}
-  virtual double Evaluate() const { return _val; }  
-  virtual void  Print(ostream& os) const { os << _val; }
+  virtual double Evaluate() const { return (*_pval); }  
+  virtual void  Print(ostream& os) const { os << (*_pval); }
 protected:
   double _val;
+  double* _pval; 
 };
 
 CE_NumberExp::CE_NumberExp(string const & s)
 {
+  _pval=&_val; 
   size_t l = s.length();
   if (l < 1) { 
@@ -64,5 +67,5 @@
   else if (s == "E") _val = M_E;
   else {
-    string errmsg = "CE_NumberExp::CE_NumberExp() Bad numerical constant: ";
+    string errmsg = "CE_NumberExp::CE_NumberExp() Bad numerical constant or unknown variable: ";
     errmsg += s;
     
@@ -349,10 +352,27 @@
 
 /*! 
-  Parse the string \c sex and builds an expression.
-  Can throw CExprException exception.
-*/
-CExpressionEvaluator::CExpressionEvaluator(string const & sex)
+  Parse the character string \c exp and builds an expression. Uses the given list of variables 
+  \c varlist if a valid pointer is provided. Can throw CExprException exception.
+*/
+CExpressionEvaluator::CExpressionEvaluator(const char* exp, CE_VarListInterface* varlist)
 {
   _exp = NULL;
+  _varlist = varlist;
+  size_t off=0,stop=0;
+  string fname = "";
+  string errmsg;
+  string sexp=exp;
+  _exp=  ParseString(0,fname,sexp,off,stop,errmsg);
+  if (_exp == NULL)  throw CExprException(errmsg);
+}
+
+/*! 
+  Parse the string \c sex and builds an expression. Uses the given list of variables 
+  \c varlist if a valid pointer is provided. Can throw CExprException exception.
+*/
+CExpressionEvaluator::CExpressionEvaluator(string const & sex, CE_VarListInterface* varlist)
+{
+  _exp = NULL;
+  _varlist = varlist;
   size_t off=0,stop=0;
   string fname = "";
@@ -402,4 +422,11 @@
 }
 
+CExprBase* CExpressionEvaluator::VarNameOrNumber(string const & s)
+{
+  if (_varlist==NULL)  return new CE_NumberExp(s); 
+  double* pv=_varlist->GetVarPointer(s);
+  if (pv!=NULL) return new CE_NumberExp(pv); 
+  return new CE_NumberExp(s); 
+}
 
 CExprBase* CExpressionEvaluator::ParseString(int extype, string fname, string const & sex, 
@@ -506,5 +533,5 @@
 	    errmsg = "CExpressionEvaluator::ParseString()/ Syntax Error - rx&&cx (B)"; 
 	  }
-	  if (q > p) cx = new CE_NumberExp(sex.substr(p-osn,q-p+osn));
+	  if (q > p) cx = VarNameOrNumber(sex.substr(p-osn,q-p+osn));
 	  else cx = rx;
 	  
@@ -551,5 +578,5 @@
 	    else {
 	      if (p == q)  cx = rx;
-	      else cx = new CE_NumberExp(sex.substr(p-osn,q-p+osn));
+	      else cx = VarNameOrNumber(sex.substr(p-osn,q-p+osn));
 	      rx = Arrange_CE_BinExpStack(sbx, cx, nbx);
 	      p = q+1;  osn = 0; lastopc = opc;
@@ -573,5 +600,5 @@
       }
       else { 
-	if (p<len)  cx = new CE_NumberExp(sex.substr(p-osn));
+	if (p<len)  cx = VarNameOrNumber(sex.substr(p-osn));
 	else cx = rx;
 	rx = Arrange_CE_BinExpStack(sbx, cx);
Index: trunk/SophyaLib/SysTools/cexpre.h
===================================================================
--- trunk/SophyaLib/SysTools/cexpre.h	(revision 4034)
+++ trunk/SophyaLib/SysTools/cexpre.h	(revision 4063)
@@ -9,4 +9,6 @@
 #include <iostream>
 #include <string>
+#include <vector>
+#include <map>
 #include "pexceptions.h"
 
@@ -46,4 +48,5 @@
 };
 
+
 /*! 
   \ingroup SysTools
@@ -53,4 +56,22 @@
   {  ex.Print(s);  return(s);  }
 
+/*! 
+  \ingroup SysTools
+  \brief Interface class used by the CExpressionEvaluator class to represent a list of variables
+  or named values accessible trough a pointer.
+
+  Inherited class should define the \b GetVarPointer() method, and can optionaly redefine 
+  the \b Update() method. 
+  \sa CExpressionEvaluator
+*/
+class CE_VarListInterface {
+public:
+  //! To be called to update values corresponding to the pointers. Default implementation does nothing.
+  virtual void Update() { return; } 
+  //! Return a pointer to a double containing the value associated with \t name.  
+  virtual double* GetVarPointer(std::string const& name) = 0;
+};
+
+
 class CE_BinExp;
 class CE_FuncExp;
@@ -58,5 +79,7 @@
 class CExpressionEvaluator : public CExprBase {
 public:
-  CExpressionEvaluator(string const & sex);
+  CExpressionEvaluator(const char* sexp, CE_VarListInterface* pvlist=NULL);
+  CExpressionEvaluator(string const & sex, CE_VarListInterface* pvlist=NULL);
+
   virtual ~CExpressionEvaluator();
 //! Evaluate the expression and returns the corresponding value.
@@ -68,4 +91,6 @@
 
 protected:
+//! Parse variable names or constants and return CE_NumberExp object.
+  CExprBase* VarNameOrNumber(string const & s); 
 //! Does the parsing and builds an CExprBase object.
   CExprBase* ParseString(int extype, string fname, string const & sex, 
@@ -73,4 +98,5 @@
 
   CExprBase * _exp;
+  CE_VarListInterface* _varlist; 
 };
 
Index: trunk/SophyaLib/SysTools/commander.cc
===================================================================
--- trunk/SophyaLib/SysTools/commander.cc	(revision 4034)
+++ trunk/SophyaLib/SysTools/commander.cc	(revision 4063)
@@ -442,4 +442,55 @@
 
 // ------------------------------------------------------------
+//         Classe Cmd_CE_VarList
+// ------------------------------------------------------------
+/*!
+  \internal
+  \class SOPHYA::Cmd_CE_VarList
+  \ingroup SysTools 
+  This class, reserved for internal use by class Commander, enables the CExpressionEvaluator class 
+  to access the interpreter variable values.
+*/
+
+class Cmd_CE_VarList : public CE_VarListInterface {
+public:
+  Cmd_CE_VarList(Commander& cmd) : cmd_(cmd) { } 
+  virtual void Update();
+  virtual double* GetVarPointer(std::string const& name);
+private:
+  Commander& cmd_;
+  std::map<std::string, double> namevals_;
+};
+
+/* --Methode-- */
+void Cmd_CE_VarList::Update()
+{
+  bool exist=false;
+  string sval;
+  std::map<std::string, double>::iterator it;
+  for(it=namevals_.begin(); it!=namevals_.end(); it++) {
+    exist=cmd_.GetVar((*it).first, sval);
+    if (!exist) throw NotFoundExc("Cmd_CE_VarList::Update() missing variable !");
+    (*it).second=atof(sval.c_str());
+  }
+  return;
+}
+
+/* --Methode-- */
+double* Cmd_CE_VarList::GetVarPointer(std::string const& name)
+{
+  std::map<std::string, double>::iterator it=namevals_.find(name);
+  if (it!=namevals_.end())  return &((*it).second);
+  bool exist=false;
+  string sval;
+  exist=cmd_.GetVar(name, sval);
+  if (!exist) return NULL;
+  namevals_[name]=atof(sval.c_str());
+  it=namevals_.find(name);
+  if (it!=namevals_.end())  return &((*it).second);
+  return NULL;
+}
+
+
+// ------------------------------------------------------------
 //         Classe Commander
 // ------------------------------------------------------------
@@ -492,5 +543,5 @@
 hist.open("history.pic");
 histon = true;
-trace = false;   timing = false;
+trace = false;   timing = false;   varcexp = true;
 gltimer = NULL;
 felevel_ = 0;
@@ -561,5 +612,5 @@
 usage += "  > sleep nsec  # sleep nsec seconds \n";   
 usage += "  > readstdin varname      # reads a line from stdin into $varname \n"; 
-usage += "  > timingon  timingoff traceon  traceoff \n";
+usage += "  > timingon  timingoff traceon  traceoff varcexpon varcexpoff \n";
 RegisterHelp(kw, usage, grp);
 
@@ -1085,12 +1136,14 @@
     try {
       double res = 0.;
-      if (tokens.size() > 2) {
-	string sex = tokens[1];
+      string sex=tokens[1];
+      if (tokens.size() > 2) 
 	for(unsigned int js=2; js<tokens.size(); js++)  sex += tokens[js];
-	CExpressionEvaluator cex(sex);
+      if (varcexp) {  //--- Evaluation d'expression avec decodage de noms de variables  
+	Cmd_CE_VarList cevl(*this);
+	CExpressionEvaluator cex(sex,&cevl);
 	res = cex.Value();
       }
-      else {
-	CExpressionEvaluator cex(tokens[1]);
+      else {  //--- Evaluation d'expression SANS decodage des noms de variables  
+	CExpressionEvaluator cex(sex);
 	res = cex.Value();
       }
@@ -1957,4 +2010,8 @@
   if (gltimer)  delete gltimer;  gltimer = NULL;  timing = false; 
   }
+else if (kw == "varcexpon")  
+  { cout << "Commander::Interpret()  -> Activating variable name decoding in expression evaluation " << endl; varcexp = true; }
+else if (kw == "varcexpoff") 
+  { cout << "Commander::Interpret()  -> Deactivating variable name decoding in expression evaluation " << endl; varcexp = false; }
 else if (kw == "exec") {
   if (tokens.size() < 1) { cout << "Commander::Interpret() Usage: exec filename" << endl;  return(0); }
Index: trunk/SophyaLib/SysTools/commander.h
===================================================================
--- trunk/SophyaLib/SysTools/commander.h	(revision 4034)
+++ trunk/SophyaLib/SysTools/commander.h	(revision 4063)
@@ -257,5 +257,5 @@
   bool timing;         // Display CPU Time
   Timer* gltimer;      // pour Display CPU Time
-
+  bool varcexp;      // true -> decodage nom de variables lors d'evaluation d'expression 
 friend class CommanderBloc;  
 friend class CommanderScript;  
