Index: trunk/SophyaPI/PIext/cxxexecutor.cc
===================================================================
--- trunk/SophyaPI/PIext/cxxexecutor.cc	(revision 1261)
+++ trunk/SophyaPI/PIext/cxxexecutor.cc	(revision 1262)
@@ -96,22 +96,4 @@
 mpiac->RegisterCommand(kw, usage, this, hgrp);
 
-
-
-//// A VIRER quand variable de objmanager OK  --> Pour Reza
-kw = "c++setvar";
-usage = "c++setvar: Setting test variable \n";
-usage+= "Usage: c++setvar varname varcontent ";
-mpiac->RegisterCommand(kw, usage, this, hgrp);
-
-kw = "c++getvar";
-usage = "c++getvar: Getting test variable content\n";
-usage+= "Usage: c++getvar varname ";
-mpiac->RegisterCommand(kw, usage, this, hgrp);
-
-kw = "c++varlist";
-usage = "c++getvar: Printing test variable list\n";
-usage+= "Usage: c++varlist  ";
-mpiac->RegisterCommand(kw, usage, this, hgrp);
-//// A VIRER quand variable de objmanager OK  --> Pour Reza
 
 }
@@ -222,4 +204,28 @@
 
 /* --Methode-- */
+int CxxExecutor::ExecuteCxx(string const & code)
+{
+  int rc;
+
+  mUserCodeFn = "";
+  mUserCodeFn = "cxx_spiapp.h";
+  ofstream os(mUserCodeFn.c_str(),ios::out);
+  if(!os) {cout<<"CxxExecutor::ExecuteCxx(): unable to open "
+	       <<mUserCodeFn<<endl;  mUserCodeFn = ""; return 1;}
+  
+  os << code ;
+  os << endl ;
+
+  cout<<"CxxExecutor: User code filled from standard input into "
+      <<mUserCodeFn<<endl;
+  
+  rc = CrFile();   if(rc) return(1);
+  rc = Compile();  if(rc) return(1);
+  rc = Link();     if(rc) return(1);
+  rc = Call();     if(rc) return(1);
+  return(rc);
+}
+
+/* --Methode-- */
 int CxxExecutor::CrFile(string cfilename,string func)
 {
@@ -362,6 +368,8 @@
 for(it=varlist.Begin(); it!=varlist.End(); it++) {
   string key = (*it).first;
-  os<<"___nomobj = \""<<key<<"\";"<<endl;
-  os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
+  if (isalpha(key[0]) ) {
+    os<<"___nomobj = \""<<key<<"\";"<<endl;
+    os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
+  }
 }
 
Index: trunk/SophyaPI/PIext/cxxexecutor.h
===================================================================
--- trunk/SophyaPI/PIext/cxxexecutor.h	(revision 1261)
+++ trunk/SophyaPI/PIext/cxxexecutor.h	(revision 1262)
@@ -24,4 +24,6 @@
 
   virtual int Execute(string& keyw,vector<string>& args);
+
+  int  ExecuteCxx(string const & code);
 
   int  CrFile(string cfilename="cxx_spiapp.cc",string func="usercxx");
Index: trunk/SophyaPI/PIext/cxxexecwin.cc
===================================================================
--- trunk/SophyaPI/PIext/cxxexecwin.cc	(revision 1261)
+++ trunk/SophyaPI/PIext/cxxexecwin.cc	(revision 1262)
@@ -92,19 +92,5 @@
       dap->SetBusy();
       mBut[0]->SetUnSensitive();
-      //  $CHECK$  REZA + CMV 23/10/2000 - Faire quelque chose de mieux ici
-      vector<string> vs;
-      int rc;
-      vs.push_back(mText->GetText());
-      rc = cxxex->FillUserCode(vs, 0);
-      if (rc) break;
-      rc = cxxex->CrFile();
-      if (rc) break;
-      rc = cxxex->Compile();
-      if (rc) break;
-      rc = cxxex->Link();
-      if (rc) break;
-      rc = cxxex->Call();
-      if (rc) break;
-      // End de $CHECK$  REZA + CMV 23/10/2000
+      cxxex->ExecuteCxx(mText->GetText());
       mBut[0]->SetSensitive();
       dap->SetReady();
Index: trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- trunk/SophyaPI/PIext/piacmd.cc	(revision 1261)
+++ trunk/SophyaPI/PIext/piacmd.cc	(revision 1262)
@@ -130,8 +130,10 @@
 class PIACmdBloc {
 public:
-		PIACmdBloc(PIACmd* piac, PIACmdBloc* par, vector<string>& args); 
-		~PIACmdBloc();
+  enum BType { BT_None, BT_ForeachList, BT_ForeachInt, BT_ForeachFloat };
+
+  PIACmdBloc(PIACmd* piac, PIACmdBloc* par, vector<string>& args); 
+  ~PIACmdBloc();
   inline PIACmdBloc*   Parent() { return(parent); }
-  inline bool   CheckOK() { return((typ >= 0) ? true : false); }
+  inline bool   CheckOK() { return blkok; }
   inline void	AddLine(string& line)  
     { lines.push_back(line); bloclineid.push_back(lines.size()); }
@@ -142,5 +144,6 @@
   PIACmd* piacmd;
   PIACmdBloc* parent;
-  int typ;           // 0 foreach , 1 integer loop, 2 float loop
+  bool blkok;        // true -> block OK
+  BType typ;         // foreach , integer loop, float loop, test 
   string varname;
   vector<string> strlist;
@@ -157,12 +160,13 @@
 piacmd = piac;
 parent = par;
-typ = -1;
+blkok = false;
+typ = BT_None;
 i1 = 0;  i2 = -1;  di = 1;
 f1 = 0.; f2 = -1.; df = 1.;
 if ((args.size() < 2) ||  !isalpha((int)args[0][0]) )  return; 
 varname = args[0];
-if (isalpha((int)args[1][0]) ) { // This is a foreach-integer bloc
+if (isalpha((int)args[1][0]) ) { // This is a foreach bloc with string list
   for(int kk=1; kk<args.size(); kk++) strlist.push_back(args[kk]);
-  typ = 0;
+  typ = BT_ForeachList;
   }
 else { // This is an integer or float loop
@@ -184,5 +188,5 @@
   else  a2 = aa; 
   if (fl) { 
-    typ = 2;
+    typ = BT_ForeachFloat;
     f1 = atof(a1.c_str());
     f2 = atof(a2.c_str());
@@ -191,5 +195,5 @@
     }
   else { 
-    typ = 1;
+    typ = BT_ForeachInt;
     i1 = atoi(a1.c_str());
     i2 = atoi(a2.c_str());
@@ -216,5 +220,5 @@
 int kk=0;
 char buff[32];
-if (typ == 0)   // foreach string loop
+if (typ == BT_ForeachList)   // foreach string loop
   for(k=0; k<strlist.size(); k++) {
     cmd = "set " + varname + " " + strlist[k];
@@ -226,5 +230,5 @@
       }
   }
-else if (typ == 1)  // Integer loop
+else if (typ == BT_ForeachInt)  // Integer loop
   for(int i=i1; i<i2; i+=di) {
     k++;
@@ -242,5 +246,5 @@
       }
   }
-else if (typ == 2)  // float loop
+else if (typ == BT_ForeachFloat)  // float loop
   for(float f=f1; f<f2; f+=df) {
     k++;
@@ -279,4 +283,6 @@
 curblk = NULL;
 felevel = 0;
+bloccxx = false;
+bloctest = false;
 
 cmdhgrp["All"] = 0;
@@ -449,6 +455,4 @@
 
 
-//  Pour le decoupage des commandes en lignes 
-typedef vector<string> cmdtok;
 
 /* Fonction */
@@ -474,23 +478,27 @@
 {
 int rc = 0;
-cmdtok tokens;
-CmdVarList::iterator it;
-
-// Removing leading blanks
-size_t p,q,q2,l;
+NamedObjMgr omg;
+
+// On saute de commandes vides
+size_t l;
 l = s.length();
 if (l < 1)  return(0);
+
+// On enregistre les commandes 
+if (histon) hist << s << endl;   
+
 if (s[0] == '#') return(0); // si c'est un commentaire
+
+
+// Removing leading blanks
+size_t p,q,q2;
+l = s.length();
+if (l < 1)  return(0);
+
 p=s.find_first_not_of(" \t");
 if (p < l) s = s.substr(p);
-// else return(0);
-
-// On enregistre les commandes 
-if (histon) hist << s << endl;   
-
-
-string toks,kw;
 
 // >>>> Substitution d'alias (1er mot)
+CmdVarList::iterator it;
 p = 0;
 q = s.find_first_of(" \t");
@@ -508,4 +516,5 @@
 
 // >>>> Separating keyword 
+string toks,kw;
 if (q < l)
   {  kw = s.substr(p,q-p);  toks = s.substr(q, l-q); }
@@ -533,8 +542,86 @@
   }
 
-// Nous ne sommes donc pas dans un bloc ....   
-
-// >>>> Variable substitution  
-string s2="";
+
+// Nous ne sommes donc pas dans un bloc ....  Substitution de variables
+
+// Execution de code C++
+
+if (s[0] == '@')   { 
+  CxxExecutor * cxxe = dynamic_cast<CxxExecutor *>(cxxexec);
+  if (cxxe == NULL) {
+    cerr << "PIACmd::Interpret() - BUG !!! Not a CxxExecutor " << endl;
+    return(99);
+  }
+  // Sans substitution des variables $
+  if (s[1] == '@') return(cxxe->ExecuteCxx(s.substr(2)));
+  else { // Avec substitution de variables $
+    string s2;
+    SubstituteVars(s, s2);
+    return(cxxe->ExecuteCxx(s2.substr(1)));    
+  }
+}
+
+
+string s2;
+SubstituteVars(s, s2);
+
+// >>>> Separating keyword and tokens 
+vector<string> tokens;
+
+q = s2.find(' '); 
+l = s2.length();
+if (q < l)
+  {  kw = s2.substr(0,q);  toks = s2.substr(q, l-q); }
+else { kw = s2;  toks = ""; }
+
+q = 0;
+while (q < l)  {
+  p = toks.find_first_not_of(" \t",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = toks.find_first_of(" \t",p); // la fin du token;
+  string token = toks.substr(p,q-p);
+  tokens.push_back(token);
+  }
+
+
+// Si c'est un foreach, on cree un nouveau bloc
+if (kw == "foreach") {
+  //     cout << " *DBG* We got a foreach... " << endl;
+  PIACmdBloc* bloc = new PIACmdBloc(this, curblk, tokens);
+  if (!bloc->CheckOK()) {
+    cerr << "foreach syntax Error ! " << endl;
+    delete bloc;
+    return(0);
+    }
+  felevel++;
+  if (curblk)  curblk->AddBloc(bloc);
+  else {
+    char prompt[64];
+    sprintf(prompt, "foreach-%d> ", felevel);
+    mImgApp->GetConsole()->SetPrompt(prompt);
+    }
+  curblk = bloc;
+  //  cout << " *DBG* New Bloc created ... " << endl;
+  return(0);
+  }
+
+else rc = ExecuteCommandLine(kw, tokens, toks);
+return(rc);
+
+// cout << "PIACmd::Do() DBG  KeyW= " << kw << " NbArgs= " << tokens.size() << endl;
+//  for(int ii=0; ii<tokens.size(); ii++)
+//  cout << "arg[ " << ii << " ] : " << tokens[ii] << endl;
+
+}
+
+/* --Methode-- */
+int PIACmd::SubstituteVars(string & s, string & s2)
+//  Variable substitution  
+{
+NamedObjMgr omg;
+
+size_t p,q,q2,l;
+
+s2="";
 p = 0;
 l = s.length();
@@ -569,10 +656,9 @@
       }
     vn = s.substr(q+2,q2-q-2);
-    it =  mVars.find(vn);  
-    if ( (vn.length() < 1) || (it == mVars.end()) ) {
+    if ( (vn.length() < 1) || (!omg.HasVar(vn)) )  {
       cerr << " Error: Undefined variable " << vn << " ! " << endl;
       return(0);
       }
-    vn = mVars[vn];
+    vn = omg.GetVar(vn);
     q2++;
     }
@@ -582,10 +668,9 @@
     vn = s.substr(q+1, q2-q-1); 
     }
-  it =  mVars.find(vn);  
-  if ( (vn.length() < 1) || (it == mVars.end()) ) {
+  if ( (vn.length() < 1) || (!omg.HasVar(vn)) )  {
     cerr << " Error: Undefined variable " << vn << " ! " << endl;
     return(0);
     }
-  s2 += (s.substr(p, q-p) + (*it).second);
+  s2 += (s.substr(p, q-p) + omg.GetVar(vn));
   p = q2;
   } 
@@ -595,50 +680,15 @@
 if (p < l) s2 = s2.substr(p);
 
-
-// >>>> Separating keyword and tokens 
-q = s2.find(' '); 
-l = s2.length();
-if (q < l)
-  {  kw = s2.substr(0,q);  toks = s2.substr(q, l-q); }
-else { kw = s2;  toks = ""; }
-
-q = 0;
-while (q < l)  {
-  p = toks.find_first_not_of(" \t",q+1); // au debut d'un token
-  if (p>=l) break;
-  q = toks.find_first_of(" \t",p); // la fin du token;
-  string token = toks.substr(p,q-p);
-  tokens.push_back(token);
-  }
-
-
-// Si c'est un foreach, on cree un nouveau bloc
-if (kw == "foreach") {
-  //     cout << " *DBG* We got a foreach... " << endl;
-  PIACmdBloc* bloc = new PIACmdBloc(this, curblk, tokens);
-  if (!bloc->CheckOK()) {
-    cerr << "foreach syntax Error ! " << endl;
-    delete bloc;
-    return(0);
-    }
-  felevel++;
-  if (curblk)  curblk->AddBloc(bloc);
-  else {
-    char prompt[64];
-    sprintf(prompt, "foreach-%d> ", felevel);
-    mImgApp->GetConsole()->SetPrompt(prompt);
-    }
-  curblk = bloc;
-  //  cout << " *DBG* New Bloc created ... " << endl;
-  return(0);
-  }
-
-
-// cout << "PIACmd::Do() DBG  KeyW= " << kw << " NbArgs= " << tokens.size() << endl;
-//  for(int ii=0; ii<tokens.size(); ii++)
-//  cout << "arg[ " << ii << " ] : " << tokens[ii] << endl;
+return(0);
+}
+
+/* --Methode-- */
+int PIACmd::ExecuteCommandLine(string & kw, vector<string> & tokens, string & toks)
+{
+int rc = 0;
+NamedObjMgr omg;
 
 // >>>>>>>>>>> Commande d'interpreteur
-else if (kw == "helpwindow") ShowHelpWindow();
+if (kw == "helpwindow") ShowHelpWindow();
 else if (kw == "help") {
   if (tokens.size() > 0) cout << GetUsage(tokens[0]) << endl;
@@ -657,11 +707,10 @@
   string xx = tokens[1];
   for (int kk=2; kk<tokens.size(); kk++)  xx += (' ' + tokens[kk] );
-  mVars[tokens[0]] = xx;
+  omg.SetVar(tokens[0], xx);
   }
 
 else if (kw == "getvar") {
   if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: getvar newvarname varname" << endl;  return(0); }
-  it = mVars.find(tokens[1]);
-  if (it == mVars.end()) {
+  if (!omg.HasVar(tokens[1])) {
     cerr << "Error - No " << tokens[1] << " Variable " << endl;
     return(0);
@@ -671,5 +720,5 @@
     return(0);
     }
-  mVars[tokens[0]] = (*it).second;
+  omg.SetVar(tokens[0], omg.GetVar(tokens[1]) );
   }
 
@@ -699,10 +748,9 @@
     for (int kk=1; kk<ol.size(); kk++)  vol += (' ' + ol[kk]);
     }
-  mVars[tokens[0]] = vol;
+  omg.SetVar(tokens[0], vol);
   }
 else if (kw == "unset") {
   if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: unset varname" << endl;  return(0); }
-  CmdVarList::iterator it = mVars.find(tokens[0]);
-  if (it != mVars.end())  mVars.erase(it);
+  if (omg.HasVar(tokens[0])) omg.DeleteVar(tokens[0]) ;
   else cerr << "PIACmd::Interpret() No variable with name " << tokens[0] << endl;
   }
@@ -720,12 +768,16 @@
   mImgApp->GetConsole()->AddStr(">>> Reading From StdIn \n", PIVA_Magenta);
   cout << tokens[0] << " ? " << endl;
-  mVars[tokens[0]] = GetStringFrStdin(this);
+  omg.SetVar(tokens[0], GetStringFrStdin(this) );
   }
 
 else if (kw == "listvars") {
   cout << "PIACmd::Interpret()  Variable List , VarName = Value \n";
-  CmdVarList::iterator it;
-  for(it = mVars.begin(); it != mVars.end(); it++)  
-    cout << (*it).first << " = " <<  (*it).second << "\n";
+  DVList& varlist = omg.GetVarList();
+  DVList::ValList::const_iterator it;
+  string value;
+  for(it = varlist.Begin(); it != varlist.End(); it++) {
+    value = (string)((*it).second.elval);
+    cout << (*it).first << " = " <<  value << "\n";
+    }
   cout << endl;
   }
@@ -774,7 +826,8 @@
 
 /* --Methode-- */
-int PIACmd::ExecuteCommandLine(string& line)
-{
-cmdtok tokens;
+int PIACmd::ParseLineExecute(string& line)
+{
+vector<string> tokens;
+
 if (line.length() < 1)  return(0);
 
@@ -843,21 +896,21 @@
 char buff[32];
 // First, we clear all previous values
+NamedObjMgr omg;
 string vn="#";
-it = mVars.find(vn);
-if (it != mVars.end())  mVars.erase(it);
+omg.DeleteVar(vn); 
 for(k=0; k<99; k++) {   
   sprintf(buff,"%d",k);
   vn = buff;
-  it = mVars.find(vn);
-  if (it != mVars.end())  mVars.erase(it);
+  omg.DeleteVar(vn); 
   }
 // We then set them
+string vval;
 vn="#";
 sprintf(buff,"%d",(int)args.size());
-mVars[vn] = buff;
+omg.SetVar(vn, buff);
 for(k=0; k<args.size(); k++) {   
   sprintf(buff,"%d",k);
   vn = buff;
-  mVars[vn] = args[k];
+  omg.SetVar(vn, args[k]);
   }
 
Index: trunk/SophyaPI/PIext/piacmd.h
===================================================================
--- trunk/SophyaPI/PIext/piacmd.h	(revision 1261)
+++ trunk/SophyaPI/PIext/piacmd.h	(revision 1262)
@@ -12,4 +12,5 @@
 #include <string>
 #include <vector>
+#include <list>
 #include <map>
 #include <functional>
@@ -78,5 +79,5 @@
 
   virtual int		Interpret(string& line);
-  virtual int		ExecuteCommandLine(string& line);
+  virtual int		ParseLineExecute(string& line);
   virtual int		ExecuteCommand(string& keyw, vector<string>& args);
   virtual int		ExecFile(string& file, vector<string>& args);
@@ -99,4 +100,9 @@
 protected:
   virtual int		CheckHelpGrp(string& grp);
+  int           ExecuteCommandLine(string & keyw, vector<string> & args,
+				   string & toks);
+
+  int           SubstituteVars(string & s, string & s2);  
+  bool	        EvaluateTest(vector<string> & args);
 
   NamedObjMgr* mObjMgr;
@@ -128,9 +134,14 @@
 //  Pour stocker les variables definies par l'interpreteur
   typedef map<string, string, less<string> > CmdVarList;
-  CmdVarList mVars;     // Liste des variables 
+  //  CmdVarList mVars;     Liste des variables 
   CmdVarList mAliases;  // Liste des alias 
 
   PIACmdBloc * curblk;  // Bloc de commande courant (foreach, ...)
   int felevel;          // foreah level 
+  list<bool> testresult;    // Resultat des test if
+  list<bool>::iterator tresit;      // Test courant
+  bool bloctest;            // On est ds un bloc test
+  bool bloccxx;             // On est ds un bloc code C++
+  string codecxx;
 
   ofstream hist;       //  History file 
