]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
Html doc
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index def347b983ed19e090ae3d26375108cc0e8dc6ee..cd640bdd9eb5957fb7fe3e8f5d6e1d659202f54a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/10/08 10:56:27 $
-  Version:   $Revision: 1.74 $
+  Date:      $Date: 2008/10/08 13:39:33 $
+  Version:   $Revision: 1.75 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -505,7 +505,7 @@ namespace bbtk
   /**
    *  
    */
-  Interpreter::ExitStatus Interpreter::InterpretFile( const std::string& filename )
+  Interpreter::ExitStatus Interpreter::InterpretFile( const std::string& filename, bool source )
   {
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
 
@@ -516,7 +516,7 @@ namespace bbtk
 
     try 
     {
-      SwitchToFile(filename);
+      SwitchToFile(filename,source);
 
       bool insideComment = false; // for multiline comment
       while (mFile.size()>0) 
@@ -722,7 +722,7 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
       case cDefine :
         if (mFileName.size()>0) 
         {
-         filename = mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back());
+                  filename = mFileName.back(); //mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back());
         }
         if (words.size()==2) 
         {
@@ -838,20 +838,17 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
         break;
 
       case cInclude :
-        if (mCommandLine)
+               // 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
+               if (mCommandLine)
         {
-           InterpretFile(words[1]); 
+           InterpretFile(words[1],(words.size()==3)); 
         }
         else
         {
-            SwitchToFile(words[1]);
+            SwitchToFile(words[1],(words.size()==3) );
         }
-       // if 'source' was given
-       if (words.size()==3) 
-         {
-           GetExecuter()->SetCurrentFileName(words[1]);
-         }
-        break;
+               break;
 
       case cLoad:
         GetExecuter()->LoadPackage(words[1]);
@@ -1022,7 +1019,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
    */
 
   // =========================================================================
-  void Interpreter::SwitchToFile( const std::string& name )
+  void Interpreter::SwitchToFile( const std::string& name , bool source )
   {
   // Note : in the following :
   // name : the user supplied name 
@@ -1296,7 +1293,10 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
        return;
       }
     else
+       {
       LoadScript(fullPathScriptName,name);
+         if (source) GetExecuter()->SetCurrentFileName(fullPathScriptName);
+       }
     
     return;
   }
@@ -1354,7 +1354,7 @@ void Interpreter::SwitchToStream( std::stringstream* stream )
     mIncludeFileName.push_back(includeScriptName);
     mLine.push_back(0);
 
-    return;
+       return;
   }
 
   //=======================================================================