]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdExecBbiCommand.cxx
*** empty log message ***
[bbtk.git] / packages / std / src / bbstdExecBbiCommand.cxx
index 0310c090375f27c50f60033921b83ddee5183b53..c52598db56ac542e2d0de94b024a9678c8b3e062 100755 (executable)
@@ -1,12 +1,13 @@
 #include "bbstdExecBbiCommand.h"
 #include "bbstdPackage.h"
 #include "bbtkInterpreter.h"
+#include "bbtkExecuter.h"
 
 namespace bbstd
 {
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecBbiCommand);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox);
 
   void ExecBbiCommand::bbUserConstructor() 
   { 
@@ -16,38 +17,59 @@ namespace bbstd
 
   void ExecBbiCommand::DoProcess()
     {
-       int i;
-       
-       bool ok=true;
-       int pos1=0,pos2;
-       pos2 = bbGetInputIn().find(";",pos1);
-       std::string ccommand;
-       while (ok==true)
+      /*
+      // Look for the interpreter
+      bbtk::Interpreter* I = 0;
+         bool delete_inter = false; 
+         if (bbGetParent() != 0) 
+       {
+         bbtk::Factory* f = ((bbtk::ComplexBlackBoxDescriptor*)bbGetParent()
+                       ->bbGetDescriptor())->GetFactory();
+         if ((f != 0)&&
+             (f->GetExecuter()))
+           {
+             I = f->GetExecuter()->GetInterpreter();
+           }
+       }
+      if (I==0) 
        {
-               if (pos2==-1) 
+         //      bbtkError("ExecBbiCommand::DoProcess() : could not find interpreter");
+         I = new bbtk::Interpreter();
+         delete_inter = true; 
+       }
+
+      int i;
+      
+      bool ok=true;
+      int pos1=0,pos2;
+      pos2 = bbGetInputIn().find(";",pos1);
+      std::string ccommand;
+      while (ok==true)
+       {
+         if (pos2==-1) 
+           {
+             ok=false;
+             ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
+           } else {
+           ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
+         }
+         for ( i=0 ; i < ccommand.length() ; i++)
+           {
+             if (ccommand[i]==39)
                {
-                       ok=false;
-                       ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
-               } else {
-                       ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
+                 ccommand[i]=34;
                }
-               for ( i=0 ; i < ccommand.length() ; i++)
-               {
-                       if (ccommand[i]==39)
-                       {
-                               ccommand[i]=34;
-                       }
-               }               
-      bool insideComment = false; // for multiline comment
-               bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand, insideComment);
-               pos1=pos2+1;
-               pos2 = bbGetInputIn().find(";",pos2+1);
-
-       }
+           }           
        
-
-
-/*  Grrr  not works in windows
+         I->InterpretLine( ccommand );
+         pos1=pos2+1;
+         pos2 = bbGetInputIn().find(";",pos2+1);
+         
+       }
+      
+      if (delete_inter) delete I;
+      */
+      /*  Grrr  not works in windows
        char * pch;
        pch = strtok (bbGetInputIn(),";");
        while (pch != NULL)