#-----------------------------------------------------------------------------
 
 
+#---Documentation-------------
+#http://www.cmake.org/Wiki/CMake:Packaging_With_CPack
+#http://www.cmake.org/Wiki/CMake:CPackConfiguration
+#http://www.cmake.org/Wiki/CMake:Install_Commands
 
 
 
   SET(CPACK_STRIP_FILES "bin/bbi")
   SET(CPACK_SOURCE_STRIP_FILES "")
 ENDIF(WIN32 AND NOT UNIX)
-SET(CPACK_PACKAGE_EXECUTABLES "bbi" "bbs interpreter")
+SET(CPACK_PACKAGE_EXECUTABLES "bbi" "bbs interpreter" )
+  
+
 INCLUDE(CPack)
 
 
 # Configure / Install the template xml files used by bbCreateBlackBox
 # Copy it into build tree
+
 FILE(GLOB_RECURSE LST_FILE_VOID_CREATE_PACKAGE RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/xml-templates *.xml )
 FOREACH( iLST  ${LST_FILE_VOID_CREATE_PACKAGE})
      STRING(SUBSTRING ${iLST} 0 3 subStrTmp )
 
 echo Creating XML file..
 echo copy %INPUT%\%type%-template.xml %OUTPUT%\%FILENAME%.xml
 copy %INPUT%\%type%-template.xml %OUTPUT%\%FILENAME%.xml_tmp
-%BINPATH%\bbSed %OUTPUT%\%FILENAME%.xml_tmp  __BLACKBOXNAME__ %BLACKBOX% > %OUTPUT%\%FILENAME%_1.xml
-%BINPATH%\bbSed %OUTPUT%\%FILENAME%_1.xml  __AUTHOR__ %AUTHOR% > %OUTPUT%\%FILENAME%_2.xml
-%BINPATH%\bbSed %OUTPUT%\%FILENAME%_2.xml  __DESCRIPTION__ %DESCRIPTION% > %OUTPUT%\%FILENAME%.xml_tmp
+"%BINPATH%\bbSed" %OUTPUT%\%FILENAME%.xml_tmp  __BLACKBOXNAME__ %BLACKBOX% > %OUTPUT%\%FILENAME%_1.xml
+"%BINPATH%\bbSed" %OUTPUT%\%FILENAME%_1.xml  __AUTHOR__ %AUTHOR% > %OUTPUT%\%FILENAME%_2.xml
+"%BINPATH%\bbSed" %OUTPUT%\%FILENAME%_2.xml  __DESCRIPTION__ %DESCRIPTION% > %OUTPUT%\%FILENAME%.xml_tmp
 del %OUTPUT%\%FILENAME%_1.xml 
-del %OUTPUT%\%FILENAME%_2.xml 
+del %OUTPUT%\%FILENAME%_2.xml
 
 
 IF %FORMAT%==XML GOTO module_XML
 
 :module_C++
   IF EXIST %OUTPUT%\%FILENAME%.cxx GOTO ERROR02
-  echo %BINPATH%\bbfy %OUTPUT%\%FILENAME%.xml_tmp %PACK% %OUTPUT% 
-  %BINPATH%\bbfy %OUTPUT%\%FILENAME%.xml_tmp %PACK% %OUTPUT%\
+  echo "%BINPATH%\bbfy" %OUTPUT%\%FILENAME%.xml_tmp %PACK% %OUTPUT% 
+  "%BINPATH%\bbfy" %OUTPUT%\%FILENAME%.xml_tmp %PACK% %OUTPUT%\
   del %OUTPUT%\%FILENAME%.xml_tmp 
 goto END
 
 
     #include directives to be put in the .h generated
     There must be one tag per file to include
     Here we include the standard header iostream.h -->
-  <include><PRE>
-    iostream.h
-  </PRE></include>
+  <include><PRE>iostream</PRE></include>
   <!--=====================================================================-->
 
   <!--========================================================================
 
-FILE(GLOB ALL "*.*")
+
+FILE(GLOB_RECURSE ALL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.*")
 
 # TO DO : REMOVE CMakeLists.txt FROM LIST !!!
 
 FOREACH(file ${ALL})
-  CONFIGURE_FILE(
-    ${file}
-    ${BBTK_DATA_BUILD_PATH}/${BBTK_PACKAGE_NAME}/${filename}
-    COPYONLY IMMEDIATE
-    )
+       set(ok "true")
+
+       IF( ${file} STREQUAL "CMakeLists.txt")
+               set(ok "false")
+       ENDIF( ${file} STREQUAL "CMakeLists.txt")
+
+       IF(${ok} STREQUAL "true" )
+               CONFIGURE_FILE(
+                       ${CMAKE_CURRENT_SOURCE_DIR}/${file}
+                       ${BBTK_DATA_BUILD_PATH}/${BBTK_PACKAGE_NAME}/${file}
+                       COPYONLY IMMEDIATE
+               )
+               ###### This mecanism is maded at the end of th system..#####
+               #INSTALL(  
+               #  FILES ${file}
+               #  DESTINATION ${BBTK_DATA_INSTALL_PATH}/${BBTK_PACKAGE_NAME}/${file}
+               #) 
+       ENDIF(${ok} STREQUAL "true" )
 ENDFOREACH(file ${ALL})
   
-INSTALL( 
-  FILES ${ALL}
-  DESTINATION ${BBTK_DATA_INSTALL_PATH}/${BBTK_PACKAGE_NAME}
-  )  
   
 
 
 
 ENDIF(UNIX)
 
 
+# Aditional INSTALL for CPACK mecanism.
+
+
+
+IF(WIN32)
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkCommon.dll                DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkDICOMParser.dll                   DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkexoIIc.dll                DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkexpat.dll                 DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkFiltering.dll             DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkfreetype.dll              DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkftgl.dll                  DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkGenericFiltering.dll      DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkGraphics.dll              DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkHybrid.dll                DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkImaging.dll               DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkIO.dll                    DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkjpeg.dll                  DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkNetCDF.dll                DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkpng.dll                           DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkRendering.dll             DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtksys.dll                           DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtktiff.dll                  DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkVolumeRendering.dll       DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkWidgets.dll               DESTINATION bin/ )
+  INSTALL(   FILES ${VTK_DIR}/bin/Release/vtkzlib.dll                  DESTINATION bin/ )
+
+  INSTALL(   FILES ${ITK_DIR}/bin/Release/ITKCommon.dll                DESTINATION bin/ )
+
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_xrc_vc_custom.dll                 DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_richtext_vc_custom.dll    DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_qa_vc_custom.dll          DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_media_vc_custom.dll       DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_html_vc_custom.dll        DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_gl_vc_custom.dll          DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_core_vc_custom.dll        DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_aui_vc_custom.dll                 DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_adv_vc_custom.dll                 DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_xml_vc_custom.dll                DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_vc_custom.dll                    DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_odbc_vc_custom.dll       DESTINATION bin/ )
+  INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_net_vc_custom.dll                DESTINATION bin/ )
+ENDIF(WIN32)
+
+
+
+# ????????? Why this line doesn't works ...?????
+FILE(GLOB_RECURSE LST_FILE_VTKDLL RELATIVE ${VTK_DIR} *.dll )
+
+FOREACH( iLST  ${LST_FILE_VTKDLL} )
+message("eed3 " ${iLST} )
+  INSTALL( 
+    FILES ${iLST}
+    DESTINATION bin/
+  )
+ENDFOREACH(iLST)
+
+
 INSTALL(
   DIRECTORY  ${BBTK_BINARY_DIR}/${BBTK_DOC_REL_PATH}
   DESTINATION  ${BBTK_SHARE_REL_PATH}
 
 #include "bbtkMessageManager.h"
 
 
-
+ 
 namespace bbtk
 {
   // Adapted from https://savannah.cern.ch/support/download.php?file_id=1972
 
   Program:   bbtk
   Module:    $RCSfile: bbtkWxConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/18 12:51:26 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2008/03/19 12:26:07 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
   //================================================================
   void WxConsole::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
   {
+printf("EED WxConsole::OnMenuCreatePackage 01 \n");
     std::string command("toolsbbtk/appli/CreatePackage");
+printf("EED WxConsole::OnMenuCreatePackage 02 \n");
+
     bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
+printf("EED WxConsole::OnMenuCreatePackage 03 \n");
     Interpreter* I = new Interpreter;    
+printf("EED WxConsole::OnMenuCreatePackage 04 \n");
     I->InterpretFile(command);
+printf("EED WxConsole::OnMenuCreatePackage 05 \n");
     delete I;
+printf("EED WxConsole::OnMenuCreatePackage 06 \n");
   }
   //================================================================
 
 
--- /dev/null
+load std
+load wx
+
+new ASCII asciiA
+  set asciiA.In "72 105 33"
+
+new ASCII asciiB
+  set asciiB.In "SOS"
+  set asciiB.type 1
+
+print $asciiA.Out$
+print $asciiB.Out$
 
--- /dev/null
+#include "bbstdASCII.h"
+#include "bbstdPackage.h"
+namespace bbstd
+{
+
+       BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ASCII)
+       BBTK_USER_BLACK_BOX_IMPLEMENTATION(ASCII,bbtk::AtomicBlackBox);
+       void ASCII::Process()
+       {
+               int asciiValue;
+               char strTmp[10];
+               std::string result("");
+               if (bbGetInputIn()!=""){
+
+                       if (bbGetInputtype()==0){
+                               std::string commandstr(bbGetInputIn());
+                               bool ok=true;
+                               int pos1=0,pos2;
+                               pos2 = commandstr.find(" ",pos1);
+                               std::string ccommand;
+                               while (ok==true)
+                               {
+                                       if (pos2==-1)   
+                                       {
+                                               ok=false;
+                                               ccommand=commandstr.substr(pos1,commandstr.length()-pos1 );
+                                       }       else  {
+                                               ccommand=commandstr.substr(pos1,pos2-pos1);
+                                       }
+                                       asciiValue = atoi( ccommand.c_str() );
+                                       sprintf(strTmp,"%c",asciiValue);
+                                       result += strTmp;
+
+                                       pos1=pos2+1;
+                                       pos2 = commandstr.find(" ",pos2+1);
+                               } // while
+                       } // if type 0
+
+                       if (bbGetInputtype()==1){
+                               int i,size=bbGetInputIn().size();
+                               for (i=0;i<size;i++){
+                                       asciiValue = (int)bbGetInputIn()[i];
+                                       sprintf(strTmp,"%d",asciiValue);
+                                       result +=strTmp;
+                                       if (i!=size-1) {
+                                               result +=" ";
+                                       } // i!=size-1
+                               } // for
+                       } // type 1
+               }
+               bbSetOutputOut( result );  
+       }
+
+       void ASCII::bbUserConstructor()
+       {
+       bbSetInputIn("");
+       bbSetInputtype(0);
+       }
+
+       void ASCII::bbUserCopyConstructor()
+       {
+
+       }
+
+       void ASCII::bbUserDestructor()
+       {
+       }
+}
+// EO namespace bbstd
+
+
 
--- /dev/null
+#ifndef __bbstdASCII_h_INCLUDED__
+#define __bbstdASCII_h_INCLUDED__
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbstd
+{
+
+class /*BBTK_EXPORT*/ ASCII
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_USER_BLACK_BOX_INTERFACE(ASCII,bbtk::AtomicBlackBox);
+//==================================================================
+/// User callback called in the box contructor
+virtual void bbUserConstructor();
+/// User callback called in the box copy constructor
+virtual void bbUserCopyConstructor();
+/// User callback called in the box destructor
+virtual void bbUserDestructor();
+//==================================================================
+  BBTK_DECLARE_INPUT(In,std::string);
+  BBTK_DECLARE_INPUT(type,int);
+  BBTK_DECLARE_OUTPUT(Out,std::string);
+  BBTK_PROCESS(Process);
+  void Process();
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ASCII,bbtk::AtomicBlackBox);
+  BBTK_NAME("ASCII");  
+  BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
+  BBTK_DESCRIPTION("ascii to string - string to ascii");
+  BBTK_CATEGORY("__CATEGORY__");
+  BBTK_INPUT(ASCII,In,"Input Ascii number or Ascii",std::string);
+  BBTK_INPUT(ASCII,type,"type (default 0) 0=AsciiNum_To_String, 1=String_To_AsciiNum",int);
+  BBTK_OUTPUT(ASCII,Out,"Ascii number or Ascii",std::string);
+BBTK_END_DESCRIBE_BLACK_BOX(ASCII);
+}
+// EO namespace bbstd
+
+#endif // __bbstdASCII_h_INCLUDED__
+
 
                ccommand[i]=34;
              }
          }                     
-       
        system ( ccommand.c_str() );
        pos1=pos2+1;
        pos2 = bbGetInputIn().find(";",pos2+1);
 
   connect typeBlackbox.Widget layoutHor.Widget1
   connect formatBlackbox.Widget layoutHor.Widget2
 
-new CommandButton cancelButton
-    set cancelButton.In "quit"
-    set cancelButton.Label "Cancel"
+#new CommandButton cancelButton
+#    set cancelButton.In "quit"
+#    set cancelButton.Label "Cancel"
 
 new CommandButton createButton
-    set createButton.In "exec command; quit"
-    set createButton.Label "Go"
+    set createButton.In "print $concatStr.Out$; exec command; "
+    set createButton.Label "Run"
 
 new LayoutLine buttons
     set buttons.Orientation Horizontal
-    connect cancelButton.Widget buttons.Widget1
+#    connect cancelButton.Widget buttons.Widget1
     connect createButton.Widget buttons.Widget2
 
 new LayoutLine main
 
 #---------------------------------------------------------------------
 
+new ASCII ascii
+  set ascii.In 34
+
 new ConcatStrings dirStr
- connect dir.Out dirStr.In1
- set dirStr.In2 " "
+ set dirStr.In1 " "
+ connect ascii.Out dirStr.In2
+ connect dir.Out dirStr.In3
+ connect ascii.Out dirStr.In4
+ set dirStr.In5 " "
 
 new ConcatStrings packageNameStr
  connect namePackage.Out packageNameStr.In1
  set formatStr.In2 " "
 
 new ConcatStrings authorStr
- connect author.Out authorStr.In1
- set authorStr.In2 " "
+ set authorStr.In1 " '"
+ connect author.Out authorStr.In2
+ set authorStr.In3 "' "
 
 new ConcatStrings descriptionStr
- connect description.Out descriptionStr.In1
- set descriptionStr.In2 " "
+ set descriptionStr.In1 " '"
+ connect description.Out descriptionStr.In2
+ set descriptionStr.In3 "' "
 
 new Configuration conf
 
 new ConcatStrings commandStr
-    connect conf.BinPath commandStr.In1        
-    connect conf.FileSeparator commandStr.In2 
-    set commandStr.In3 "bbCreateBlackBox "
+    set                                                commandStr.In1 " "
+    connect ascii.Out                  commandStr.In2
+    connect conf.BinPath               commandStr.In3
+    connect conf.FileSeparator commandStr.In4
+    set                                                commandStr.In5 "bbCreateBlackBox"
+    connect ascii.Out                  commandStr.In6
+    set                                                commandStr.In7 " "
+
 
 new ConcatStrings concatStr
     connect  commandStr.Out            concatStr.In1 
     connect authorStr.Out                      concatStr.In7
     connect descriptionStr.Out         concatStr.In8
 
+new ConcatStrings concatStr2
+    connect  ascii.Out                         concatStr2.In1 
+    connect concatStr.Out                      concatStr2.In2 
+    connect ascii.Out                          concatStr2.In3
 
 new ExecSystemCommand command
-    connect concatStr.Out command.In
-    print $concatStr.Out$
+    connect concatStr2.Out command.In
 
+exec dir
 exec main
 
 
     set description.Title "Description            (caracters   '<',  '>' not accepted...)"
     set description.In "_description_"
 
-new CommandButton cancelButton
-    set cancelButton.In "quit"
-    set cancelButton.Label "Cancel"
+#new CommandButton cancelButton
+#    set cancelButton.In "quit"
+#    set cancelButton.Label "Cancel"
 
 new CommandButton createButton
-    set createButton.In "exec command; quit"
-    set createButton.Label "Go"
+    set createButton.In "print $concatStr.Out$; exec command; "
+    set createButton.Label "Run"
 
 new LayoutLine buttons
     set buttons.Orientation Horizontal
-    connect cancelButton.Widget buttons.Widget1
+ #   connect cancelButton.Widget buttons.Widget1
     connect createButton.Widget buttons.Widget2
 
 new LayoutLine main
     set main.WinHeight 250 
 
 
+new ASCII ascii
+  set ascii.In 34
+
+new ConcatStrings dirStr
+ set dirStr.In1 " "
+ connect ascii.Out dirStr.In2
+ connect dir.Out dirStr.In3
+ connect ascii.Out dirStr.In4
+ set dirStr.In5 " "
+
+new ConcatStrings nameStr
+ set nameStr.In1 "  "
+ connect name.Out nameStr.In2
+ set nameStr.In3 " "
+
+new ConcatStrings authorStr
+ set authorStr.In1 " '"
+ connect author.Out authorStr.In2
+ set authorStr.In3 "' "
+
+new ConcatStrings descriptionStr
+ set descriptionStr.In1 " '"
+ connect description.Out descriptionStr.In2
+ set descriptionStr.In3 "' "
+
+
+
 new Configuration conf
 new ConcatStrings concatStrCommand
-#    set concatStrCommand.In1 "."
-    connect conf.BinPath concatStrCommand.In1
-    connect conf.FileSeparator concatStrCommand.In2 
-    set concatStrCommand.In3 "bbCreatePackage "
+    set concatStrCommand.In1 " "
+    connect ascii.Out                  concatStrCommand.In2
+    connect conf.BinPath               concatStrCommand.In3
+    connect conf.FileSeparator concatStrCommand.In4
+    set                                                concatStrCommand.In5  "bbCreatePackage"
+    connect ascii.Out                  concatStrCommand.In6
+    set                                                concatStrCommand.In7  " "
+
 new ConcatStrings concatStr
-    connect  concatStrCommand.Out concatStr.In1 
-    connect dir.Out concatStr.In2 
-    set concatStr.In3 " "
-    connect name.Out concatStr.In4 
-    set concatStr.In5 " '"
-    connect author.Out concatStr.In6 
-    set concatStr.In7 "' '"
-    connect description.Out concatStr.In8 
-    set concatStr.In9 "'"
+    connect ascii.Out                          concatStr.In1
+    connect  concatStrCommand.Out concatStr.In2
+    connect dirStr.Out                         concatStr.In3
+    connect nameStr.Out                        concatStr.In4 
+    connect authorStr.Out                      concatStr.In5 
+    connect descriptionStr.Out         concatStr.In6
+    connect ascii.Out                          concatStr.In7
 
 
 new ExecSystemCommand command
     connect concatStr.Out command.In
-    print $concatStr.Out$
 
+exec dir
 exec main
 
 
   Program:   bbtk
   Module:    $RCSfile: bbwxCommandButton.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/10 06:24:13 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/03/19 12:26:09 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 
   l'Image). All rights reserved. See Doc/License.txt or
          }
        for ( i=0 ; i < ccommand.length() ; i++)
          {
-           if (ccommand[i]==39)
+           if (ccommand[i]==39) // '
              {
-               ccommand[i]=34;
+               ccommand[i]=34;  // "
              }
          }             
        bool insideComment = false; // for multiline comment