Index: trunk/SophyaLib/SysTools/commander.cc
===================================================================
--- trunk/SophyaLib/SysTools/commander.cc	(revision 2473)
+++ trunk/SophyaLib/SysTools/commander.cc	(revision 2483)
@@ -10,4 +10,5 @@
 
 
+namespace SOPHYA {
 // ------------------------------------------------------------
 //         Bloc de commandes (Foreach, ...)    
@@ -21,5 +22,6 @@
 class CommanderBloc {
 public:
-  enum BType { BT_None, BT_ForeachList, BT_ForeachInt, BT_ForeachFloat };
+  enum BType { BT_None, BT_ForeachList, BT_ForeachInt, BT_ForeachFloat, 
+	       BT_ForeachLineInFile };
 
   CommanderBloc(Commander* piac, CommanderBloc* par, string& kw, vector<string>& args); 
@@ -44,4 +46,5 @@
   BType typ;         // foreach , integer loop, float loop, test 
   string varname;
+  string filename;   // forinfile bloc
   vector<string> strlist;
   vector<string> lines;
@@ -68,13 +71,17 @@
 
 if ((args.size() < 2) ||  !isalpha((int)args[0][0]) )  return; 
-if ((kw != "foreach") && (kw != "for"))  return;
+if ((kw != "foreach") && (kw != "for") && (kw != "forinfile"))  return;
 varname = args[0];  // $CHECK$ Variable name should be checked 
 //if (isalpha((int)args[1][0]) ) {  This is a foreach bloc with string list
-if (kw == "foreach" ) { // This is a foreach bloc with string list
+if (kw == "forinfile") {
+  filename = args[1];
+  blkok = true;
+}
+else if (kw == "foreach" ) { // This is a foreach bloc with string list
   if ((args[1] != "(") || (args[args.size()-1] != ")") ) return;
   for(int kk=2; kk<args.size()-1; kk++) strlist.push_back(args[kk]);
   typ = BT_ForeachList;
   blkok = true;
-  }
+}
 else { // This is an integer or float loop
   size_t l = args[1].length();
@@ -144,5 +151,7 @@
 int mxloop = _commander->GetMaxLoopLimit();
 
-if (typ == BT_ForeachList)   // foreach string loop
+if (typ == BT_ForeachLineInFile) {  // foreach line in file loop
+}
+else if (typ == BT_ForeachList)   // foreach string loop
   for(k=0; k<strlist.size(); k++) {
     cmd = "set " + varname + " '" + strlist[k] + "'";
@@ -313,5 +322,9 @@
 spromptmul = "Cmd> ";
 SetCurrentPrompt(spromptmul);
+SetDefaultPrompt(spromptmul);
 curscript = NULL;
+
+_xstatus = 0;
+ _retstr = "";
 
 CmdBlks.push(NULL);
@@ -612,5 +625,6 @@
     cerr << "Commander::Interpret()/syntax error near end else endif endscript \n"
 	 << "line: " << s << endl;
-    return(1);
+    _xstatus = 91;
+    return(91);
   }
 }
@@ -633,4 +647,5 @@
       SetCurrentPrompt("Cmd> ");
       curscript = NULL;
+      _xstatus = 0;
       return(0);
     }
@@ -640,8 +655,10 @@
       SetCurrentPrompt("Cmd> ");
       curscript = NULL;
-      return(2);
+      _xstatus = 92;
+      return(92);
     }
   }
   else curscript->AddLine(s, kw);
+  _xstatus = 0;
   return(0);
 }
@@ -658,5 +675,6 @@
 	   << " within for/foreach bloc ! " << endl;
       delete curb;
-      return(2);  
+      _xstatus = 93;
+      return(93);  
     }
        //       cout << " *DBG* Executing bloc " << endl;
@@ -672,8 +690,10 @@
       PopStack(false);
     }
+    SetCurrentPrompt(defprompt);
     delete curb;
     histon = ohv;
   }
   else CmdBlks.top()->AddLine(s, kw); 
+  _xstatus = 0;
   return(0);
 }
@@ -681,5 +701,6 @@
   cerr << "Commander::Interpret()/syntax error - end outside for/foreach bloc \n"
        << "line: " << s << endl;
-  return(1);  
+  _xstatus = 94;
+  return(94);  
 }
 
@@ -690,5 +711,6 @@
       cerr << "Commander::Interpret()/syntax error - multiple else in if bloc \n"
 	   << "line: " << s << endl;
-      return(1);
+      _xstatus = 95;
+      return(95);
     }
     else { 
@@ -697,4 +719,5 @@
       SetCurrentPrompt(npr);
       (*tresit) |= 2;
+      _xstatus = 0;
       return(0);
     }
@@ -723,4 +746,5 @@
     else curtestresult = true;
     SetCurrentPrompt(npr);
+    _xstatus = 0;
     return(0);
   }
@@ -729,5 +753,6 @@
   cerr << "Commander::Interpret()/syntax error - else,endif outside if bloc \n"
        << "line: " << s << endl;
-  return(1);  
+  _xstatus = 91;
+  return(91);  
 }
 
@@ -744,10 +769,16 @@
 } 
 
-if ((!fgcont) && (kw != "if"))  return(0);
+if ((!fgcont) && (kw != "if"))  { 
+  _xstatus = 0;
+  return(0);
+}
 
 
 // Les mots cles break et return peuvent de sortir de boucles/scripts/execfile
 if (kw == "break") return(77766);
-else if (kw == "return")  return(77777);
+else if (kw == "return")  { 
+  _retstr = toks; 
+  return(77777);
+}
 
 // Nous ne sommes donc pas dans un bloc ....  Substitution de variables
@@ -759,5 +790,6 @@
   cerr << "Commander::Interpret()/syntax error in SubstituteVars() \n"
        << "line: " << s << endl;
-  return(rcs);
+  _xstatus = 99;
+  return(99);
 }
 // >>>> Separating keyword and tokens 
@@ -767,5 +799,5 @@
 
 // Si c'est un for/foreach, on cree un nouveau bloc
-if ((kw == "foreach") || (kw == "for")) {
+if ((kw == "foreach") || (kw == "for") || (kw == "forinfile") ) {
   //     cout << " *DBG* We got a foreach... " << endl;
   CommanderBloc* bloc = new CommanderBloc(this, CmdBlks.top(), kw, tokens);
@@ -773,5 +805,6 @@
     cerr << "Commander::Interpret() for/foreach syntax Error ! " << endl;
     delete bloc;
-    return(1);
+    _xstatus = 91;
+    return(91);
     }
   felevel++;
@@ -787,5 +820,6 @@
   if (rct) {
     cerr << "Commander::Interpret() if syntax Error ! " << "line: " << s << endl;
-    return(1);
+    _xstatus = 91;
+    return(91);
   }
   char res_tst = (restst) ? 1 : 0;
@@ -802,5 +836,6 @@
   if (rcev) {
     cerr << "Commander::Interpret() evaluation (RPN) syntax Error ! " << "line: " << s << endl;
-    return(1);
+    _xstatus = 98;
+    return(98);
   }
   return(0);
@@ -815,5 +850,6 @@
   else {
     cerr << "Commander::Interpret() No script name in defscript" << "line: " << s << endl;
-    return(1);
+    _xstatus = 91;
+    return(91);
   }
 }
@@ -832,4 +868,5 @@
   //  Execution de commandes 
   else rc = ExecuteCommandLine(kw, tokens, toks);
+  _xstatus = rc;
   return(rc);
 }  
@@ -941,5 +978,5 @@
       }
     vn = s.substr(q+2,q2-q-2);
-    if (!GetVar(vn, vv)) return(5);
+    if (!Var2Str(vn, vv)) return(5);
     vn = vv;
     q2++;
@@ -961,5 +998,5 @@
       if (isalpha(sia[0])) {
 	string sia2;
-	if (!GetVar(sia, sia2) || (sia2.length() < 1)) {
+	if (!Var2Str(sia, sia2) || (sia2.length() < 1)) {
 	  cerr << " Syntax error - in $varname[index] : $"  
 	       << vn << "[" << sia <<"]" << endl;
@@ -976,18 +1013,16 @@
     }
   }
-  if (!GetVar(vn, vv)) return(5);
   if (iarr < 0) {
+    if (!Var2Str(vn, vv)) return(5);
     s2 += (s.substr(p, q-p) + vv);
     p = q2;
   }
   else {
-    vector<string> vs;
-    FillVStringFrString(vv, vs);
-    if (iarr >= vs.size()) {
+    if (! Var2Str(vn, iarr, vv) ) { 
       cerr << " Substitution error - word index out of range in "
 	   << "$varname[iarr] : $" << vn << "[" << iarr <<"]" << endl;
       return(4);
     }
-    else s2 += (s.substr(p, q-p) + vs[iarr]);
+    else s2 += (s.substr(p, q-p) + vv);
     p = q3+1;
   }
@@ -1002,5 +1037,5 @@
 
 /* --Methode-- */
-bool Commander::GetVar(string & vn, string & vv)
+bool Commander::Var2Str(string const & vn, string & vv)
 {
 if (vn.length() < 1) {
@@ -1010,4 +1045,6 @@
 // Variable de type $# $0 $1 ... (argument de .pic ou de script)
 int ka = 0;
+char buff[32];
+  
 if (vn == "#") {
   if (ArgsStack.empty()) {
@@ -1035,81 +1072,295 @@
 }
 else if (vn[0] == '#') {  // Variable de type $#vname --> size(vname) 
-  vn = vn.substr(1);
-  if (!HasVariable(vn) ) {
+  CmdVarList::iterator it = variables.find(vn.substr(1));
+  if (it == variables.end()) {
     cerr << " Commander::SubstituteVarError: Undefined variable " 
 	 << vn << " ! " << endl;
     vv = "";  return(false);
   }
-  vn = GetVariable(vn);
-  vector<string> vs;
-  FillVStringFrString(vn, vs);
-  char buff[32];
-  sprintf(buff,"%d", (int)vs.size());
+  sprintf(buff,"%d", (int)(*it).second.size());
   vv = buff; return(true);
-  } 
-else {  // variable ordinaire geree par NamedObjMgr
-  if ( (!HasVariable(vn)) )  {
+} 
+else if (vn == "status") {
+  sprintf(buff,"%d", _xstatus);
+  vv = buff;
+  return true;
+}
+else if (vn == "retstr") {
+  vv = _retstr;
+  return true;
+}
+else {  // Variable de l'interpreteur, ou de l'environnement application , env. global
+  if (GetVar(vn, vv))  return true;
+  else if (GetVarApp(vn, vv))  return true;
+  else if (GetVarEnv(vn, vv))  return true;
+  else { 
     cerr << " Commander::SubstituteVarError: Undefined variable " 
 	 << vn << " ! " << endl;
-    vv = "";  return(false);
-  }
-  vv = GetVariable(vn);  return(true);
-}
-
-return(false);
-}
-/* --Methode-- */
-string Commander::GetVariable(string const & key)
-{
-  if ((key.length() < 1) || (! isalpha(key[0])) )   {
-    cout << "Commander::GetVariable( " << key << ") Bad VarName " << endl;
-    return("");
-  }
-  // cout << " DEBUG::GetVar " << variables << endl;
-  return(variables.GetS(key));
-}
-
-/* --Methode-- */
-bool Commander::HasVariable(string const & key)
-{
-  if ((key.length() < 1) || (! isalpha(key[0])) )   {
-    cout << "Commander::HasVar( " << key << ") Bad VarName " << endl;
+    vv = "";  return false;
+  }
+}
+
+return false;
+}
+
+/* --Methode-- */
+bool Commander::SetVariable(string const & vn, string const & vv)
+{
+  // On verifie si le nom est de type vname[idx]
+  size_t p,q,l;
+  l = vn.length();
+  p = vn.find('[');
+  if (p < l) {
+    q = vn.find(']');
+    if (q != (l-1)) {
+      cout << "Commander::Str2Var/SetVar() - Bad varname with []: " 
+	   << vn << endl;
+      return false;
+    }
+    string vna = vn.substr(0, p);
+    string sia = vn.substr(p+1, q-(p+1));
+    if (isalpha(sia[0])) {
+      string sia2;
+      if (!Var2Str(sia, sia2) || (sia2.length() < 1)) {
+	cerr << "Commander::Str2Var/SetVar() Syntax error- varname[index]:"  
+	     << vn << endl;
+	return false;	  
+      }
+      sia = sia2;
+    }
+    int iarr;
+    int rcdia = ctoi(sia.c_str(), &iarr);
+    if (rcdia < 0) {
+      cerr << "Commander::Str2Var/SetVar() Syntax error- varname[iarr]: " 
+	   << vn << endl;
+      return false;
+    }
+    return SetVar(vna, iarr, vv);
+  }
+  else { 
+    if (vn == "status") { 
+      _xstatus = atoi(vv.c_str());
+      return true;
+    }
+    else if (vn == "retstr") { 
+      _retstr = vv;
+      return true;
+    }
+    else return SetVar(vn, vv);
+  }
+}
+
+/* --Methode-- */
+bool Commander::GetVar(string const & vn, string & vv)
+{
+  CmdVarList::iterator it = variables.find(vn);
+  if (it == variables.end()) {
+    vv = "";
+    return false;
+  }
+  vv = (*it).second[0]; 
+  if ((*it).second.size() > 1) {   
+    for(int k=1; k<(*it).second.size(); k++) {
+      vv += ' ';  vv += (*it).second[k];
+    }
+  }
+  return true;
+}
+
+/* --Methode-- */
+bool Commander::GetVar(string const & vn, int idx, string & vv)
+{
+  vv = "";
+  CmdVarList::iterator it = variables.find(vn);
+  if (it == variables.end())  return false;
+  if ((idx < 0) || (idx > (*it).second.size()-1))
+    return false;
+  vv = (*it).second[idx];
+  return true;
+}
+
+/* --Methode-- */
+bool Commander::GetVar(string const & vn, vector<string> & vv)
+{
+  vv.clear();
+  //  vv.erase(vv.begin(),vv.end());
+  CmdVarList::iterator it = variables.find(vn);
+  if (it == variables.end())  return false;
+  vv = (*it).second;
+  return true;
+}
+
+/* --Methode-- */
+bool Commander::SetVar(string const & vn, string const & val)
+{
+  if ( !CheckVarName(vn) )  {
+    cerr << "Commander::SetVar( " << vn << " ...) Bad VarName " << endl;
     return(false);
   }
-  return(variables.HasKey(key));
-}
-
-/* --Methode-- */
-bool Commander::SetVar(string const & key, string const & val)
-{
-   if ((key.length() < 1) || (! isalpha(key[0])) )   {
-    cout << "Commander::SetVar( " << key << " ...) Bad VarName " << endl;
+  bool fg = false;
+  vector<string> nouv;
+  nouv.push_back(val);
+  CmdVarList::iterator it = variables.find(vn);
+  if (it == variables.end())  variables[vn] = nouv;
+  else { 
+    (*it).second = nouv;
+    fg = true;
+  }
+  return fg;
+}
+
+/* --Methode-- */
+bool Commander::SetVar(string const & vn, int idx, string const & val)
+{
+  if ( !CheckVarName(vn) )  {
+    cerr << "Commander::SetVar( " << vn << " ,idx, ...) Bad VarName " << endl;
     return(false);
   }
-  bool fg = variables.HasKey(key);
-  variables.SetS(key, val);
-  // cout << " DEBUG::SetVar " << variables << endl;
+  if ((vn == "status") || (vn == "retstr")) {
+    cerr << "Commander::SetVar(vn,idx,val) ERROR - special var status/retstr " 
+	 << endl;
+    return(false);
+  }
+  if (idx < 0) {
+    cout << "Commander::SetVar(vn," << idx << ",...) Error idx < 0" << endl;
+    return(false);
+  }
+  bool fg = false;
+  CmdVarList::iterator it = variables.find(vn);
+  if (it == variables.end()) {
+    vector<string> nouv;
+    for(int j=0; j<idx; j++)  nouv.push_back("");
+    nouv.push_back(val);
+    variables[vn] = nouv;
+  }
+  else { 
+    if (idx >= (*it).second.size())
+      for(int j=(*it).second.size(); j<idx; j++)  (*it).second.push_back("");
+    (*it).second.push_back(val);
+    fg = true;
+  }
   return fg;
 }
 
 /* --Methode-- */
-bool Commander::DeleteVar(string const & key)
-{
-  if ((key.length() < 1) || (! isalpha(key[0])) )   {
-    cout << "Commander::DeleteVar( " << key << ") Bad VarName " << endl;
+bool Commander::SetVar(string const & vn, vector<string> const & val)
+{
+  if ( !CheckVarName(vn) )  {
+    cerr << "Commander::SetVar( " << vn << " ...) Bad VarName " << endl;
     return(false);
   }
-  return(variables.DeleteKey(key));
-}
-
-/* --Methode-- */
-void Commander::ListVars()
-{
-  cout << " ---- Commander::ListVars() List of defined variables ---- " 
+  if ((vn == "status") || (vn == "retstr")) {
+    cerr << "Commander::SetVar(vn, vector<string>) ERROR - special var status/retstr " 
+	 << endl;
+    return(false);
+  }
+  bool fg = false;
+  CmdVarList::iterator it = variables.find(vn);
+  if (it == variables.end())  variables[vn] = val;
+  else { 
+    (*it).second = val;
+    fg = true;
+  }
+  return fg;
+}
+
+/* --Methode-- */
+bool Commander::CheckVarName(string const & vn)
+{
+  size_t l,k;
+  l = vn.length();
+  if (l < 1)  return false;
+  if (!isalpha(vn[0]))  return false;
+  for(k=1; k<l; k++) 
+    if ((!isalnum(vn[k])) && (vn[k] != '_'))  return false;
+  return true;  
+}
+
+/* --Methode-- */
+bool Commander::DeleteVar(string const & vn)
+{
+  CmdVarList::iterator it = variables.find(vn);
+  if (it == variables.end())  { 
+    cerr << "Commander::DeleteVar() Var " << vn << " undefined!" << endl;
+    return false;
+  }
+  variables.erase(it);
+  return true;
+}
+
+/* --Methode-- */
+void Commander::ListVar()
+{
+  cout << " ---- Commander::ListVar() List of defined variables ---- " 
        << endl;
-  cout << variables;
+  CmdVarList::iterator it;
+  for(it = variables.begin(); it != variables.end(); it++) {
+    string vn = (*it).first;  
+    int vs = (*it).second.size();
+    cout << vn << " -> Size= " << vs  << endl;
+  }
   cout << "---------------------------------------------------------- " 
        << endl;
 }
+
+/* --Methode-- */
+bool Commander::GetVarApp(string const & vn, string & vv)
+{
+  vv = "";
+  cout << " Commander::GetVarApp() Not available ! " << endl;
+  return false;
+}
+
+/* --Methode-- */
+bool Commander::SetVarApp(string const & vn, string const & vv)
+{
+  cout << " Commander::SetVarApp() Not available ! " << endl;
+  return false;  
+}
+
+/* --Methode-- */
+bool Commander::DeleteVarApp(string const & vn)
+{
+  cout << " Commander::DeleteVarApp() Not available ! " << endl;
+  return false;  
+}
+
+/* --Methode-- */
+void Commander::ListVarApp()
+{
+  cout << " Commander::ListVarApp() Not available ! " << endl;
+  return;  
+}
+
+
+/* --Methode-- */
+bool Commander::GetVarEnv(string const & vn, string & vv)
+{
+  vv = "";
+  cout << " Commander::GetVarEnv() Not available ! " << endl;
+  return false;
+}
+
+/* --Methode-- */
+bool Commander::SetVarEnv(string const & vn, string const & vv)
+{
+  cout << " Commander::SetVarEnv() Not available ! " << endl;
+  return false;  
+}
+
+/* --Methode-- */
+bool Commander::DeleteVarEnv(string const & vn)
+{
+  cout << " Commander::DeleteVarEnv() Not available ! " << endl;
+  return false;  
+}
+
+/* --Methode-- */
+void Commander::ListVarEnv()
+{
+  cout << " Commander::ListVarEnv() Not available ! " << endl;
+  return;  
+}
+
 
 /* --Methode-- */
@@ -1228,5 +1479,5 @@
   }
   else if (args.size() == 2) { 
-    SetVar(args[0], args[1]);
+    SetVariable(args[0], args[1]);
     return(0); 
   }
@@ -1415,5 +1666,5 @@
   sprintf(buff, "%g", x);
   string res = buff;
-  SetVar(args[0], res);
+  SetVariable(args[0], res);
   return(0);
 }
@@ -1461,14 +1712,15 @@
 
 else if (kw == "set") {
-  if (tokens.size() < 2) { cout << "Commander::Interpret() Usage: set varname string" << endl;  return(0); }
-  if ((tokens[0].length() < 1) || !isalpha((int)tokens[0][0]) ) {
-    cerr << "Commander::Interpret()/Error Variable name should start with alphabetic" << endl;
-    return(0);
-    }
-  //  string xx = tokens[1];
-  //  for (int kk=2; kk<tokens.size(); kk++)  xx += (' ' + tokens[kk] );
-  SetVar(tokens[0], tokens[1]);
-  }
-
+  if (tokens.size() < 2) { cout << "Commander::Interpret() Usage: set varname value" << endl;  return(0); }
+  if (tokens.size() == 2) 
+    SetVariable(tokens[0], tokens[1]);
+  else {
+    vector<string> vv;
+    for(int k=1; k<tokens.size(); k++)  vv.push_back(tokens[k]);
+    SetVar(tokens[0], vv);
+  }
+  return 0;
+}
+/*  RZDELETE
 else if (kw == "getvar") {
   if (tokens.size() < 2) { cout << "Commander::Interpret() Usage: getvar newvarname varname" << endl;  return(0); }
@@ -1483,5 +1735,5 @@
   SetVar(tokens[0], GetVariable(tokens[1]) );
   }
-
+  END-RZDELETE */
 else if (kw == "alias") {
   if (tokens.size() < 2) { cout << "Commander::Interpret() Usage: alias aliasname string" << endl;  return(0); }
@@ -1489,16 +1741,19 @@
     cerr << "Commander::Interpret()/Error alias name should start with alphabetic" << endl;
     return(0);
-    }
+  }
   string xx = tokens[1];
   for (int kk=2; kk<tokens.size(); kk++)  xx += (' ' + tokens[kk]);
   mAliases[tokens[0]] = xx;
-  }
-
-else if (kw == "unset") {
-  if (tokens.size() < 1) { cout << "Commander::Interpret() Usage: unset varname" << endl;  return(0); }
-  if (HasVariable(tokens[0])) DeleteVar(tokens[0]) ;
-  else cerr << "Commander::Interpret() No variable with name " << tokens[0] << endl;
-  }
- else if (kw == "rpneval") {  // Evaluation d'expression en notation polonaise inverse
+}
+
+else if ( (kw == "unset") || (kw == "clearvar") ) {
+  if (tokens.size() < 1) { 
+    cout << "Commander::Interpret() Usage: unset/clearvar varname" << endl;  
+    return(0); 
+  }
+  else DeleteVar(tokens[0]);
+}
+// Evaluation d'expression en notation polonaise inverse
+else if (kw == "rpneval") {  
   return(EvalRPNExpr(tokens, toks));
 }
@@ -1529,5 +1784,5 @@
   }
 
-else if (kw == "listvars") ListVars();
+else if (kw == "listvar") ListVar();
 else if (kw == "listalias") {
   cout << "Commander::Interpret()  Alias List , AliasName = Value \n";
@@ -1897,3 +2152,4 @@
 
 
-
+}  // End of namespace SOPHYA
+
Index: trunk/SophyaLib/SysTools/commander.h
===================================================================
--- trunk/SophyaLib/SysTools/commander.h	(revision 2473)
+++ trunk/SophyaLib/SysTools/commander.h	(revision 2483)
@@ -22,4 +22,5 @@
 #include "ctimer.h"
 
+namespace SOPHYA {
 // Classe definissant l'interface pour un executeur de commande
 
@@ -49,18 +50,4 @@
 class CommanderScript;  // Script de commandes defini ds l'interpreteur Commander
 
-/*
-//! Interface definition for SOPHYA::Commander help manager
-class CommanderHelpMgr {
-public :
-			CommanderHelpMgr();
-  virtual		~CommanderHelpMgr();
-  virtual void		AddHelpGroup(const char * hgrp, int gid);
-  virtual void		AddHelpItem(const char * hitem);
-  virtual void          ClearHelpList();
-  virtual void		Activate();
-}
-*/
-
-
 //! A simple command interpreter with c-shell like syntax with dynamic load capability.
 
@@ -104,6 +91,5 @@
   inline  CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
 
-
-//   Utilitaire pour decoupage en mot
+  //   Utilitaire pour decoupage en mot
   static  int   LineToWords(string& line, string& kw, vector<string>& tokens,
 			    string& toks, bool uq=true);
@@ -123,10 +109,34 @@
   int	        EvalRPNExpr(vector<string> & args, string & line);
 
-  virtual bool    GetVar(string & vn, string & vv);
-  virtual string  GetVariable(string const & vn);
-  virtual bool    HasVariable(string const & vn);
+  // Acces aux variables 
+  virtual bool    Var2Str(string const & vn, string & vv);
+  inline  bool    Var2Str(string const & vn, int idx, string & vv)
+  { return GetVar(vn, idx, vv); }
+  inline  bool    Var2Str(string const & vn, vector<string> & vv)
+  { return GetVar(vn, vv); }
+
+  // ----- Action / gestion des variables propres de l'interpreteur
+  // Verifie l'existence de la variable nomme vn et retourne sa valeur ds vv
+  // Retourne false si la variable n'existe pas
+  virtual bool    SetVariable(string const & vn, string const & vv);
+  virtual bool    GetVar(string const & vn, string & vv);
+  virtual bool    GetVar(string const & vn, int idx, string & vv);
+  virtual bool    GetVar(string const & vn, vector<string> & vv);
   virtual bool    SetVar(string const & vn, string const & vv);
+  virtual bool    SetVar(string const & vn, int idx, string const & vv);
+  virtual bool    SetVar(string const & vn, vector<string> const & vv);
+  virtual bool    CheckVarName(string const & vn);
   virtual bool    DeleteVar(string const & vn);
-  virtual void    ListVars();
+  virtual void    ListVar();
+  // Variables de l'environnement application 
+  virtual bool    GetVarApp(string const & vn, string & vv);
+  virtual bool    SetVarApp(string const & vn, string const & vv);
+  virtual bool    DeleteVarApp(string const & vn);
+  virtual void    ListVarApp();
+  // Variables d'environnement globales 
+  virtual bool    GetVarEnv(string const & vn, string & vv);
+  virtual bool    SetVarEnv(string const & vn, string const & vv);
+  virtual bool    DeleteVarEnv(string const & vn);
+  virtual void    ListVarEnv();
 
   virtual string  GetTmpDir();
@@ -134,4 +144,5 @@
   virtual void  SetCurrentPrompt(const char* pr);
   inline void   SetCurrentPrompt(string const & pr) { SetCurrentPrompt(pr.c_str()); }
+  inline void   SetDefaultPrompt(string const & pr) { defprompt = pr; }
 
   virtual void	ShowMessage(const char * msg, int att);
@@ -143,5 +154,6 @@
 
 // Gestion des variables
-  DVList variables;
+  typedef map< string,  vector<string>, less<string> > CmdVarList;
+  CmdVarList variables;
 
 // Pour enregistrer la liste de commandes et leurs executeurs et le help
@@ -168,13 +180,19 @@
   CommanderScript* curscript; // Script en cours de definition
 
-//  Pour stocker les alias definies par l'interpreteur
+  // Code de retour execution commande
+  int _xstatus;
+  // Valeur de retour (par l'instruction return) - 
+  string _retstr;
+
+  //  Pour stocker les alias definies par l'interpreteur
   typedef map<string, string, less<string> > CmdStrList;
   CmdStrList mAliases;  // Liste des alias 
 
-// Le stack pour les arguments des .pic et des scripts
+  // Le stack pour les arguments des .pic et des scripts
   stack< vector<string> > ArgsStack;
-// Stack pour les Prompts
+  // Stack pour les Prompts
   stack<string> PromptStack; 
 
+  // Gestion des blocs de commandes et tests (if) 
   stack< CommanderBloc * > CmdBlks;  // Bloc de commande courant (foreach, ...)
   int felevel;                    // foreach-for level 
@@ -184,9 +202,14 @@
   bool curtestresult;             // Resultat courant des tests 
 
+  // Commande splitees sur plusieurs lignes
   bool mulinefg;            // Bloc multi-lignes (ligne suite)
   string mulinecmd;         // Commande multi-lignes
+
+  // Texte de prompt (attente de commande)
   string spromptmul;        // Prompt console avant multi-ligne
-  string curprompt;
-
+  string curprompt;         // Prompt courant
+  string defprompt;         // Prompt par defaut 
+
+  // Gestion d'historique, trace, timing des commandes
   ofstream hist;       //  History file 
   bool histon;        //  True ->  history file
@@ -195,6 +218,10 @@
   Timer* gltimer;      // pour Display CPU Time
 
+friend class CommanderBloc;  
+friend class CommanderScript;  
+
 };
 
+} // namespace SOPHYA
 
 /* end of ifdef COMMANDER_H_SEEN */
