]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index d112f73bdb4f4c19c065bde7e511962c235c2caa..fc5f3f18638104b9d3046cc162c02de60a6c5259 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/10/17 08:18:13 $
-  Version:   $Revision: 1.77 $
+  Date:      $Date: 2008/12/12 12:11:21 $
+  Version:   $Revision: 1.79 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -134,6 +134,14 @@ namespace bbtk
     info.help = "Deletes the black box of name <box>";
     mCommandDict[info.keyword] = info;
 
+    info.keyword = "clear";
+    info.argmin = 0;
+    info.argmax = 0;
+    info.code = cClear;
+    info.syntax = "clear";
+    info.help = "Clears the currently defined complex box (deletes all its boxes and connections)";
+    mCommandDict[info.keyword] = info;
+
     info.keyword = "newgui";
     info.argmin = 2;
     info.argmax = 2;
@@ -396,6 +404,28 @@ namespace bbtk
       mScriptLine(script_line)
   {
   }
+  //=======================================================================
+  void Interpreter::CatchInterpreterException( const InterpreterError& e )
+  {
+    if (mThrow) 
+      {
+       CloseAllFiles();
+       throw InterpreterError(e);
+      }
+    else
+      {
+       std::stringstream mess;
+       mess << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
+       if (e.IsInScriptFile())
+         {
+           mess << "* FILE  : \""<<e.GetScriptFile()<<"\""<<std::endl;
+           mess << "* LINE  : "<<e.GetScriptLine()<<std::endl;
+         }
+       std::cerr << mess.str();
+      }
+  }
+  //=======================================================================
+
   //=======================================================================
   void Interpreter::CatchBbtkException( const bbtk::Exception& e )
   {
@@ -496,6 +526,11 @@ namespace bbtk
       status = Interpreter_QUIT;               \
       if (mThrow) throw QuitException();       \
     }                                          \
+  catch (InterpreterError e)                   \
+    {                                          \
+      status = Interpreter_ERROR;              \
+      CatchInterpreterException(e);                    \
+    }                                          \
   catch (bbtk::Exception e)                    \
     {                                          \
       status = Interpreter_ERROR;              \
@@ -850,6 +885,10 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
        Reset();
         break;
 
+     case cClear :  
+       mVirtualExecuter->Clear();
+        break;
+
       case cInclude :
                // if 'source' was given (words.size()==3) then tell to set the 
                // source file name of the current complex box with the full file name included