Merge remote-tracking branch 'origin/master' into yasp 07/11507/2
Antoine ELIAS [Wed, 15 May 2013 09:15:11 +0000 (11:15 +0200)]
Conflicts:
scilab/configure
scilab/modules/api_scilab/Makefile.am
scilab/modules/api_scilab/Makefile.in
scilab/modules/api_scilab/api_scilab.vcxproj.filters
scilab/modules/differential_equations/sci_gateway/fortran/sci_f_dasrt.f
scilab/modules/differential_equations/sci_gateway/fortran/sci_f_dassl.f
scilab/modules/fileio/src/c/mput.c
scilab/modules/matio/sci_gateway/c/gw_matio.c
scilab/modules/matio/sci_gateway/c/sci_matfile_close.c
scilab/modules/matio/sci_gateway/c/sci_matfile_listvar.c
scilab/modules/matio/sci_gateway/c/sci_matfile_open.c
scilab/modules/matio/sci_gateway/c/sci_matfile_varreadnext.c
scilab/modules/matio/sci_gateway/c/sci_matfile_varwrite.c
scilab/modules/matio/src/c/CreateBooleanVariable.c
scilab/modules/matio/src/c/CreateCellVariable.c
scilab/modules/matio/src/c/CreateCharVariable.c
scilab/modules/matio/src/c/CreateDoubleVariable.c
scilab/modules/matio/src/c/CreateHyperMatrixVariable.c
scilab/modules/matio/src/c/CreateIntegerVariable.c
scilab/modules/matio/src/c/CreateMatlabVariable.c
scilab/modules/matio/src/c/CreateMatlabVariable.h
scilab/modules/matio/src/c/CreateSparseVariable.c
scilab/modules/matio/src/c/CreateStructVariable.c
scilab/modules/matio/src/c/GetCellVariable.c
scilab/modules/matio/src/c/GetCharVariable.c
scilab/modules/matio/src/c/GetDoubleVariable.c
scilab/modules/matio/src/c/GetIntegerVariable.c
scilab/modules/matio/src/c/GetMatlabVariable.c
scilab/modules/matio/src/c/GetMatlabVariable.h
scilab/modules/matio/src/c/GetMlistVariable.c
scilab/modules/matio/src/c/GetSparseVariable.c
scilab/modules/matio/src/c/GetStructVariable.c

Change-Id: Ic70fd5637f46587d52588a931d6a67148401a094

29 files changed:
1  2 
scilab/.gitignore
scilab/configure
scilab/configure.ac
scilab/modules/api_scilab/Makefile.am
scilab/modules/api_scilab/Makefile.in
scilab/modules/api_scilab/api_scilab.vcxproj
scilab/modules/api_scilab/api_scilab.vcxproj.filters
scilab/modules/api_scilab/includes/api_scilab.h
scilab/modules/core/includes/machine.h.in
scilab/modules/matio/sci_gateway/c/sci_matfile_close.c
scilab/modules/matio/sci_gateway/c/sci_matfile_listvar.c
scilab/modules/matio/sci_gateway/c/sci_matfile_open.c
scilab/modules/matio/sci_gateway/c/sci_matfile_varreadnext.c
scilab/modules/matio/sci_gateway/c/sci_matfile_varwrite.c
scilab/modules/matio/src/c/CreateBooleanVariable.c
scilab/modules/matio/src/c/CreateCellVariable.c
scilab/modules/matio/src/c/CreateCharVariable.c
scilab/modules/matio/src/c/CreateDoubleVariable.c
scilab/modules/matio/src/c/CreateHyperMatrixVariable.c
scilab/modules/matio/src/c/CreateIntegerVariable.c
scilab/modules/matio/src/c/CreateMatlabVariable.c
scilab/modules/matio/src/c/CreateMatlabVariable.h
scilab/modules/matio/src/c/CreateSparseVariable.c
scilab/modules/matio/src/c/CreateStructVariable.c
scilab/modules/matio/src/c/GetCellVariable.c
scilab/modules/matio/src/c/GetCharVariable.c
scilab/modules/matio/src/c/GetMatlabVariable.h
scilab/modules/matio/src/c/GetMlistVariable.c
scilab/modules/matio/src/c/GetSparseVariable.c

Simple merge
@@@ -26192,7 -25551,7 +26193,7 @@@ CPPFLAGS="$CPPFLAGS $TCL_INC_PATH -I$CH
  $as_echo_n "checking if tk is version $CHK_TK_MAJOR.$CHK_TK_MINOR or later... " >&6; }
  
  cat > conftest.$ac_ext <<EOF
- #line 26195 "configure"
 -#line 25554 "configure"
++#line 26196 "configure"
  #include "confdefs.h"
  
  #include "$CHK_TK_INCLUDE_PATH/$CHK_TK_INC_NAME"
@@@ -26770,7 -26133,7 +26775,7 @@@ $as_echo_n "checking saxon... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 26773 "configure"
 -// #line 26136 "configure"
++// #line 26778 "configure"
  import java.util.regex.Pattern;
  
  import com.icl.saxon.Loader;
@@@ -26887,7 -26250,7 +26892,7 @@@ $as_echo_n "checking jlatexmath-fop... 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 26890 "configure"
 -// #line 26253 "configure"
++// #line 26895 "configure"
  import java.util.regex.Pattern;
  
  import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj;
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
- #line 33318 "configure"
 -#line 32681 "configure"
++#line 33323 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
- #line 33424 "configure"
 -#line 32787 "configure"
++#line 33429 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
Simple merge
@@@ -18,30 -18,20 +18,31 @@@ src/cpp/api_string.cpp 
  src/cpp/api_pointer.cpp \
  src/cpp/api_handle.cpp \
  src/cpp/api_error.cpp \
 +src/cpp/overload.cpp \
 +src/cpp/returnProperty.cpp \
 +src/cpp/returnPropertyList.cpp \
- src/cpp/api_optional.cpp
+ src/cpp/api_optional.cpp \
+ src/cpp/api_hypermat.cpp
  
 -
 -libsciapi_scilab_la_CPPFLAGS=-I$(srcdir)/includes/ \
 +libsciapi_scilab_la_CPPFLAGS= \
 +-I$(srcdir)/includes/ \
  -I$(srcdir)/src/cpp/ \
 --I$(top_srcdir)/modules/core/includes/ \
 --I$(top_srcdir)/modules/call_scilab/includes/ \
 --I$(top_srcdir)/modules/localization/includes/ \
 --I$(top_srcdir)/modules/output_stream/includes/ \
 --I$(top_srcdir)/modules/string/includes/ \
 +-I$(srcdir)/src/c/ \
 +-I$(top_srcdir)/modules/core/includes \
 +-I$(top_srcdir)/modules/call_scilab/includes \
 +-I$(top_srcdir)/modules/localization/includes \
 +-I$(top_srcdir)/modules/output_stream/includes \
 +-I$(top_srcdir)/modules/operations/includes \
 +-I$(top_srcdir)/modules/types/includes \
 +-I$(top_srcdir)/modules/symbol/includes \
 +-I$(top_srcdir)/modules/types/includes \
 +-I$(top_srcdir)/modules/ast/includes \
 +-I$(top_srcdir)/modules/elementary_functions/includes \
 +-I$(top_srcdir)/modules/string/includes \
 +-I$(top_srcdir)/modules/dynamic_link/includes \
 +$(EIGEN_CPPFLAGS) \
  $(AM_CPPFLAGS)
  
 -
  if MAINTAINER_MODE
  pkglib_LTLIBRARIES = libsciapi_scilab.la
  else
@@@ -149,15 -149,10 +149,16 @@@ am__objects_1 = libsciapi_scilab_la-api
        libsciapi_scilab_la-api_pointer.lo \
        libsciapi_scilab_la-api_handle.lo \
        libsciapi_scilab_la-api_error.lo \
 +      libsciapi_scilab_la-overload.lo \
 +      libsciapi_scilab_la-returnProperty.lo \
 +      libsciapi_scilab_la-returnPropertyList.lo \
-       libsciapi_scilab_la-api_optional.lo
+       libsciapi_scilab_la-api_optional.lo \
+       libsciapi_scilab_la-api_hypermat.lo
  am_libsciapi_scilab_la_OBJECTS = $(am__objects_1)
  libsciapi_scilab_la_OBJECTS = $(am_libsciapi_scilab_la_OBJECTS)
 +libsciapi_scilab_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
 +      $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 +      $(CXXFLAGS) $(libsciapi_scilab_la_LDFLAGS) $(LDFLAGS) -o $@
  @MAINTAINER_MODE_FALSE@am_libsciapi_scilab_la_rpath =
  @MAINTAINER_MODE_TRUE@am_libsciapi_scilab_la_rpath = -rpath \
  @MAINTAINER_MODE_TRUE@        $(pkglibdir)
@@@ -465,28 -452,16 +466,29 @@@ src/cpp/api_string.cpp 
  src/cpp/api_pointer.cpp \
  src/cpp/api_handle.cpp \
  src/cpp/api_error.cpp \
 +src/cpp/overload.cpp \
 +src/cpp/returnProperty.cpp \
 +src/cpp/returnPropertyList.cpp \
- src/cpp/api_optional.cpp
+ src/cpp/api_optional.cpp \
+ src/cpp/api_hypermat.cpp
  
 -libsciapi_scilab_la_CPPFLAGS = -I$(srcdir)/includes/ \
 +libsciapi_scilab_la_CPPFLAGS = \
 +-I$(srcdir)/includes/ \
  -I$(srcdir)/src/cpp/ \
 --I$(top_srcdir)/modules/core/includes/ \
 --I$(top_srcdir)/modules/call_scilab/includes/ \
 --I$(top_srcdir)/modules/localization/includes/ \
 --I$(top_srcdir)/modules/output_stream/includes/ \
 --I$(top_srcdir)/modules/string/includes/ \
 +-I$(srcdir)/src/c/ \
 +-I$(top_srcdir)/modules/core/includes \
 +-I$(top_srcdir)/modules/call_scilab/includes \
 +-I$(top_srcdir)/modules/localization/includes \
 +-I$(top_srcdir)/modules/output_stream/includes \
 +-I$(top_srcdir)/modules/operations/includes \
 +-I$(top_srcdir)/modules/types/includes \
 +-I$(top_srcdir)/modules/symbol/includes \
 +-I$(top_srcdir)/modules/types/includes \
 +-I$(top_srcdir)/modules/ast/includes \
 +-I$(top_srcdir)/modules/elementary_functions/includes \
 +-I$(top_srcdir)/modules/string/includes \
 +-I$(top_srcdir)/modules/dynamic_link/includes \
 +$(EIGEN_CPPFLAGS) \
  $(AM_CPPFLAGS)
  
  @MAINTAINER_MODE_TRUE@pkglib_LTLIBRARIES = libsciapi_scilab.la
@@@ -1,4 -1,4 +1,4 @@@
--<?xml version="1.0" encoding="utf-8"?>
++<?xml version="1.0" encoding="utf-8"?>
  <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
      <Filter Include="Source Files">
      <ClCompile Include="src\cpp\api_optional.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 +    <ClCompile Include="src\cpp\returnProperty.cpp">
 +      <Filter>Source Files</Filter>
 +    </ClCompile>
 +    <ClCompile Include="src\cpp\returnPropertyList.cpp">
 +      <Filter>Source Files</Filter>
 +    </ClCompile>
+     <ClCompile Include="src\cpp\api_hypermat.cpp">
+       <Filter>Source Files</Filter>
+     </ClCompile>
    </ItemGroup>
    <ItemGroup>
      <ClInclude Include="includes\api_boolean.h">
      <ClInclude Include="includes\api_optional.h">
        <Filter>Header Files</Filter>
      </ClInclude>
 +    <ClInclude Include="includes\returnProperty.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="includes\returnPropertyList.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
+     <ClInclude Include="includes\api_hypermat.h">
+       <Filter>Header Files</Filter>
+     </ClInclude>
    </ItemGroup>
    <ItemGroup>
      <ResourceCompile Include="src\c\api_scilab.rc">
  Interface for MATIO function called Mat_Close
  Scilab function name : matfile_close
  *******************************************************************************/
- int sci_matfile_close(char* fname, void* pvApiCtx)
 -int sci_matfile_close(char *fname, unsigned long fname_len)
++int sci_matfile_close(char *fname, void* pvApiCtx)
  {
-   mat_t * matfile = NULL;
-   int fileIndex = 0;
-   int nbRow = 0, nbCol = 0;
-   int * fd_addr = NULL;
-   int flag = 1, var_type;
-   double * fd_val = NULL;
-   SciErr _SciErr;
-   CheckRhs(1, 1);
-   CheckLhs(1, 1);
+     mat_t * matfile = NULL;
+     int fileIndex = 0;
+     int nbRow = 0, nbCol = 0;
+     int * fd_addr = NULL;
+     int flag = 1, var_type;
+     double * fd_val = NULL;
+     SciErr sciErr;
  
-   /* First Rhs is the index of the file to close */
+     CheckRhs(1, 1);
+     CheckLhs(1, 1);
  
-   _SciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr); MATIO_ERROR;
-   _SciErr = getVarType(pvApiCtx, fd_addr, &var_type); MATIO_ERROR;
+     /* First Rhs is the index of the file to close */
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
+     sciErr = getVarType(pvApiCtx, fd_addr, &var_type);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
  
-   if (var_type == sci_matrix)
+     if (var_type == sci_matrix)
      {
-       _SciErr = getMatrixOfDouble(pvApiCtx, fd_addr, &nbRow, &nbCol, &fd_val); MATIO_ERROR;
-       if (nbRow * nbCol != 1)
-       {
-         Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
-         return 1;
-       }
-       fileIndex = (int)*fd_val;
+         sciErr = getMatrixOfDouble(pvApiCtx, fd_addr, &nbRow, &nbCol, &fd_val);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 0;
+         }
+         if (nbRow * nbCol != 1)
+         {
+             Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
+             return FALSE;
+         }
+         fileIndex = (int) * fd_val;
      }
-   else
+     else
      {
-       Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
-       return 1;
+         Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
+         return FALSE;
      }
  
-   /* Gets the corresponding matfile to close it */
-   /* The manager clears its static matfile table */
-   matfile_manager(MATFILEMANAGER_DELFILE, &fileIndex, &matfile);
+     /* Gets the corresponding matfile to close it */
+     /* The manager clears its static matfile table */
+     matfile_manager(MATFILEMANAGER_DELFILE, &fileIndex, &matfile);
  
-   /* If the file has not already been closed, it's closed */
-   if(matfile!=NULL)
+     /* If the file has not already been closed, it's closed */
+     if (matfile != NULL)
+     {
+         flag = Mat_Close(matfile);
+     }
+     else /* The user is informed */
      {
-       flag = Mat_Close(matfile);
+         sciprint("File already closed.\n");
      }
-   else /* The user is informed */
-     sciprint("File already closed.\n");
  
-   /* Return execution flag */
-   var_type = (flag == 0);
-   createScalarBoolean(pvApiCtx, Rhs+1, var_type); MATIO_ERROR;
+     /* Return execution flag */
+     var_type = (flag == 0);
+     createScalarBoolean(pvApiCtx, Rhs + 1, var_type);
  
-   LhsVar(1) = Rhs+1;
+     LhsVar(1) = Rhs + 1;
  
-   PutLhsVar();
+     PutLhsVar();
  
-   return 0;
+     return TRUE;
  }
  #include "Scierror.h"
  #include "MALLOC.h"
  #include "freeArrayOfString.h"
 -#ifdef _MSC_VER
 -#include "strdup_Windows.h"
 -#endif
 +#include "os_strdup.h"
  
- #define MATIO_ERROR if(_SciErr.iErr)       \
-     {                                      \
-       printError(&_SciErr, 0);                     \
-       return 1;                                    \
 -int sci_matfile_listvar(char *fname, unsigned long fname_len)
++int sci_matfile_listvar(char *fname, void* pvApiCtx)
+ {
+     int nbRow = 0, nbCol = 0;
+     mat_t *matfile = NULL;
+     matvar_t *matvar = NULL;
+     int fileIndex = 0;
+     char **varnames = NULL;
+     double *varclasses = NULL;
+     double *vartypes = NULL;
+     int nbvar = 0, var_type;
+     int * fd_addr = NULL;
+     double tmp_dbl;
+     SciErr sciErr;
+     CheckRhs(1, 1);
+     CheckLhs(1, 3);
+     /* First Rhs is the index of the file to read */
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
+     sciErr = getVarType(pvApiCtx, fd_addr, &var_type);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
      }
  
- int sci_matfile_listvar(char* fname, void* pvApiCtx)
- {
-   int nbRow = 0, nbCol = 0;
-   mat_t *matfile = NULL;
-   matvar_t *matvar = NULL;
-   int fileIndex = 0;
-   char **varnames = NULL;
-   double *varclasses = NULL;
-   double *vartypes = NULL;
-   int nbvar = 0, var_type;
-   int * fd_addr = NULL;
-   double tmp_dbl;
-   SciErr _SciErr;
-   CheckRhs(1, 1);
-   CheckLhs(1, 3);
-   /* First Rhs is the index of the file to read */
-   _SciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr); MATIO_ERROR;
-   _SciErr = getVarType(pvApiCtx, fd_addr, &var_type); MATIO_ERROR;
-   if (var_type == sci_matrix)
+     if (var_type == sci_matrix)
      {
-       getScalarDouble(pvApiCtx, fd_addr, &tmp_dbl);
-       if (!isScalar(pvApiCtx, fd_addr))
-       {
-         Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
-         return 1;
-       }
-       fileIndex = (int)tmp_dbl;
+         getScalarDouble(pvApiCtx, fd_addr, &tmp_dbl);
+         if (!isScalar(pvApiCtx, fd_addr))
+         {
+             Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
+             return FALSE;
+         }
+         fileIndex = (int)tmp_dbl;
      }
-   else
+     else
      {
-       Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
-       return 1;
+         Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
+         return FALSE;
      }
  
-   /* Gets the corresponding matfile */
-   matfile_manager(MATFILEMANAGER_GETFILE, &fileIndex, &matfile);
-   if (matfile == NULL)
-   {
-       Scierror(999, _("%s: Invalid file identifier.\n"), fname);
-       return FALSE;
-   }
-   
-   /* Back to the beginning of the file */
-   if (Mat_Rewind(matfile) != 0)
+     /* Gets the corresponding matfile */
+     matfile_manager(MATFILEMANAGER_GETFILE, &fileIndex, &matfile);
+     if (matfile == NULL)
      {
-       Scierror(999, _("%s: Could not rewind the file %s.\n"), "matfile_listvar", matfile->filename);
-       return 1;
+         Scierror(999, _("%s: Invalid file identifier.\n"), fname);
+         return FALSE;
      }
  
-   matvar = Mat_VarReadNext(matfile);
-   while (matvar != NULL && matvar->name != NULL)
+     /* Back to the beginning of the file */
+     if (Mat_Rewind(matfile) != 0)
+     {
+         Scierror(999, _("%s: Could not rewind the file %s.\n"), "matfile_listvar", Mat_GetFilename(matfile));
+         return FALSE;
+     }
+     matvar = Mat_VarReadNext(matfile);
+     while (matvar != NULL && matvar->name != NULL)
      {
          nbvar++;
          varnames = (char**) REALLOC(varnames, nbvar * sizeof(char*));
     Interface for MATIO function called Mat_Open
     Scilab function name : matfile_open
  *******************************************************************************/
 -int sci_matfile_open(char *fname, unsigned long fname_len)
 +int sci_matfile_open(char *fname, void* pvApiCtx)
  {
-   int nbRow = 0, nbCol = 0;
-   mat_t *matfile;
-   int fileIndex = 0;
-   char * filename  = NULL;
-   char * optionStr = NULL;
-   int option = 0, var_type;
-   int * filename_addr = NULL, * option_addr = NULL;
-   SciErr _SciErr;
-   CheckRhs(1, 2);
-   CheckLhs(1, 1);
-   _SciErr = getVarAddressFromPosition(pvApiCtx, 1, &filename_addr); MATIO_ERROR;
-   _SciErr = getVarType(pvApiCtx, filename_addr, &var_type); MATIO_ERROR;
-   if (var_type == sci_strings)
+     int nbRow = 0, nbCol = 0;
+     mat_t *matfile;
+     int fileIndex = 0;
+     char * filename  = NULL;
+     char * optionStr = NULL;
+     int option = 0, var_type;
+     int * filename_addr = NULL, * option_addr = NULL;
+     SciErr sciErr;
+     CheckRhs(1, 2);
+     CheckLhs(1, 1);
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &filename_addr);
+     if (sciErr.iErr)
      {
-       getAllocatedSingleString(pvApiCtx, filename_addr, &filename);
-       _SciErr = getVarDimension(pvApiCtx, filename_addr, &nbRow, &nbCol);
-       MATIO_ERROR;
-       if (nbCol != 1)
-       {
-         Scierror(999, _("%s: Wrong size for first input argument: Single string expected.\n"), fname);
-         freeAllocatedSingleString(filename);
-         return 1;
-       }
+         printError(&sciErr, 0);
+         return 0;
      }
-   else
+     sciErr = getVarType(pvApiCtx, filename_addr, &var_type);
+     if (sciErr.iErr)
      {
-       Scierror(999, _("%s: Wrong type for first input argument: Single string expected.\n"), fname);
-       freeAllocatedSingleString(filename);
+         printError(&sciErr, 0);
+         return 0;
+     }
  
-       return 1;
+     if (var_type == sci_strings)
+     {
+         getAllocatedSingleString(pvApiCtx, filename_addr, &filename);
+         sciErr = getVarDimension(pvApiCtx, filename_addr, &nbRow, &nbCol);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 0;
+         }
+         if (nbCol != 1)
+         {
+             Scierror(999, _("%s: Wrong size for first input argument: Single string expected.\n"), fname);
+             freeAllocatedSingleString(filename);
+             return FALSE;
+         }
+     }
+     else
+     {
+         Scierror(999, _("%s: Wrong type for first input argument: Single string expected.\n"), fname);
+         freeAllocatedSingleString(filename);
+         return FALSE;
      }
  
-   if (Rhs == 2)
+     if (Rhs == 2)
      {
-       _SciErr = getVarAddressFromPosition(pvApiCtx, 2, &option_addr); MATIO_ERROR;
-       _SciErr = getVarType(pvApiCtx, option_addr, &var_type); MATIO_ERROR;
-       if (var_type == sci_strings)
-       {
-         getAllocatedSingleString(pvApiCtx, option_addr, &optionStr);
-         _SciErr = getVarDimension(pvApiCtx, option_addr, &nbRow, &nbCol); MATIO_ERROR;
-         if (nbCol != 1)
-           {
-             Scierror(999, _("%s: Wrong size for second input argument: Single string expected.\n"), fname);
-             freeAllocatedSingleString(filename);
-             freeAllocatedSingleString(optionStr);
-             return 1;
-           }
-         if (strcmp(optionStr, "r")==0)
-           {
-             option = MAT_ACC_RDONLY;
-           }
-         else if (strcmp(optionStr, "w")==0)
-           {
-             option = 0; // MAT_ACC_RDWR option will be used for append mode
-           }
-         else
-           {
-             Scierror(999, _("%s: Wrong value for second input argument: 'r' or 'w' expected.\n"), fname);
-             freeAllocatedSingleString(filename);
-             freeAllocatedSingleString(optionStr);
-             return 1;
-           }
-       }
-       else
-       {
-         Scierror(999, _("%s: Wrong type for second input argument: Single string expected.\n"), fname);
-         freeAllocatedSingleString(filename);
-         freeAllocatedSingleString(optionStr);
-         return 1;
-       }
+         sciErr = getVarAddressFromPosition(pvApiCtx, 2, &option_addr);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 0;
+         }
+         sciErr = getVarType(pvApiCtx, option_addr, &var_type);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 0;
+         }
+         if (var_type == sci_strings)
+         {
+             getAllocatedSingleString(pvApiCtx, option_addr, &optionStr);
+             sciErr = getVarDimension(pvApiCtx, option_addr, &nbRow, &nbCol);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return 0;
+             }
+             if (nbCol != 1)
+             {
+                 Scierror(999, _("%s: Wrong size for second input argument: Single string expected.\n"), fname);
+                 freeAllocatedSingleString(filename);
+                 freeAllocatedSingleString(optionStr);
+                 return FALSE;
+             }
+             if (strcmp(optionStr, "r") == 0)
+             {
+                 option = MAT_ACC_RDONLY;
+             }
+             else if (strcmp(optionStr, "w") == 0)
+             {
+                 option = MAT_ACC_RDWR;
+             }
+             else
+             {
+                 Scierror(999, _("%s: Wrong value for second input argument: 'r' or 'w' expected.\n"), fname);
+                 freeAllocatedSingleString(filename);
+                 freeAllocatedSingleString(optionStr);
+                 return FALSE;
+             }
+         }
+         else
+         {
+             Scierror(999, _("%s: Wrong type for second input argument: Single string expected.\n"), fname);
+             freeAllocatedSingleString(filename);
+             freeAllocatedSingleString(optionStr);
+             return FALSE;
+         }
      }
-   else
+     else
      {
-       /* Default option value */
-       option = MAT_ACC_RDONLY;
+         /* Default option value */
+         option = MAT_ACC_RDONLY;
      }
  
-   /* Try to open the file (as a Matlab 5 file) */
-   matfile = Mat_Open(filename, option);
+     if (option == MAT_ACC_RDWR)
+     {
+         /* create a Matlab 5 file */
+         matfile = Mat_CreateVer(filename, NULL, 0);
+     }
+     else
+     {
+         /* Try to open the file (as a Matlab 5 file) */
+         matfile = Mat_Open(filename, option);
+     }
  
-   if(matfile==NULL) /* Opening failed */
+     if (matfile == NULL) /* Opening failed */
      {
-       /* Try to open the file (as a Matlab 4 file) */
-       matfile = Mat_Open(filename, option | MAT_FT_MAT4);
-       if(matfile==NULL) /* Opening failed */
-       {
-         /* Function returns -1 */
-         fileIndex = -1;
-       }
+         /* Function returns -1 */
+         fileIndex = -1;
      }
  
-   if (matfile != NULL) /* Opening succeed */
+     if (matfile != NULL) /* Opening succeed */
      {
-       /* Add the file to the manager */
-       matfile_manager(MATFILEMANAGER_ADDFILE, &fileIndex, &matfile);
+         /* Add the file to the manager */
+         matfile_manager(MATFILEMANAGER_ADDFILE, &fileIndex, &matfile);
      }
  
-   /* Return the index */
-   createScalarDouble(pvApiCtx, Rhs+1, (double)fileIndex);
+     /* Return the index */
+     createScalarDouble(pvApiCtx, Rhs + 1, (double)fileIndex);
  
-   freeAllocatedSingleString(filename);
-   freeAllocatedSingleString(optionStr);
+     freeAllocatedSingleString(filename);
+     freeAllocatedSingleString(optionStr);
  
-   LhsVar(1) = Rhs+1;
-   PutLhsVar();
+     LhsVar(1) = Rhs + 1;
+     PutLhsVar();
  
-   return 0;
+     return TRUE;
  }
  #include "Scierror.h"
  #include "sciprint.h"
  
- #define MATIO_ERROR if(_SciErr.iErr)       \
-     {                                      \
-       printError(&_SciErr, 0);                     \
-       return 0;                                    \
-     }
- enum matfile_errors {
-   NO_MORE_VARIABLES = -1,
-   UNKNOWN_VARIABLE_TYPE = 0
+ enum matfile_errors
+ {
+     NO_MORE_VARIABLES = -1,
+     UNKNOWN_VARIABLE_TYPE = 0
  };
  
- int sci_matfile_varreadnext(char* fname, void* pvApiCtx)
 -int sci_matfile_varreadnext(char *fname, unsigned long fname_len)
++int sci_matfile_varreadnext(char *fname, void* pvApiCtx)
  {
-   mat_t *matfile = NULL;
-   matvar_t *matvar = NULL;
-   int fileIndex = 0;
-   int returnedClass = 0, var_type;
-   int * fd_addr = NULL;
-   double tmp_dbl;
-   SciErr _SciErr;
+     mat_t *matfile = NULL;
+     matvar_t *matvar = NULL;
+     int fileIndex = 0;
+     int returnedClass = 0, var_type;
+     int * fd_addr = NULL;
+     double tmp_dbl;
+     SciErr sciErr;
  
-   CheckRhs(1, 1);
-   CheckLhs(1, 3);
+     CheckRhs(1, 1);
+     CheckLhs(1, 3);
  
-   /* Input argument is the index of the file to read */
+     /* Input argument is the index of the file to read */
  
-   _SciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr); MATIO_ERROR;
-   _SciErr = getVarType(pvApiCtx, fd_addr, &var_type); MATIO_ERROR;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
+     sciErr = getVarType(pvApiCtx, fd_addr, &var_type);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
  
-   if (var_type == sci_matrix)
+     if (var_type == sci_matrix)
      {
-       getScalarDouble(pvApiCtx, fd_addr, &tmp_dbl);
-       if (!isScalar(pvApiCtx, fd_addr))
-       {
-         Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
-         return 1;
-       }
-       fileIndex = (int)tmp_dbl;
+         getScalarDouble(pvApiCtx, fd_addr, &tmp_dbl);
+         if (!isScalar(pvApiCtx, fd_addr))
+         {
+             Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
+             return FALSE;
+         }
+         fileIndex = (int)tmp_dbl;
      }
-   else
+     else
      {
-       Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
-       return 1;
+         Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
+         return FALSE;
      }
  
-   /* Gets the corresponding matfile */
-   matfile_manager(MATFILEMANAGER_GETFILE, &fileIndex, &matfile);
+     /* Gets the corresponding matfile */
+     matfile_manager(MATFILEMANAGER_GETFILE, &fileIndex, &matfile);
  
-   if (matfile == NULL)
+     if (matfile == NULL)
      {
-       Scierror(999, _("%s: Invalid file identifier.\n"), fname);
-       return FALSE;
+         Scierror(999, _("%s: Invalid file identifier.\n"), fname);
+         return FALSE;
      }
  
-   matvar = Mat_VarReadNext(matfile);
-   if ((matvar == NULL) || (matvar->name == NULL))
+     matvar = Mat_VarReadNext(matfile);
+     if ((matvar == NULL) || (matvar->name == NULL))
      {
-       /* Return empty name */
-       createSingleString(pvApiCtx, Rhs+1, "\0");
-       LhsVar(1) = Rhs+1;
-       if (Lhs >= 2)
-       {
-         /* Return empty value */
-         createEmptyMatrix(pvApiCtx, Rhs+2);
-         LhsVar(2) = Rhs+2;
-       }
-       if (Lhs == 3)
-       {
-         /* Return error flag instead of variable class */
-         createScalarDouble(pvApiCtx, Rhs+3, NO_MORE_VARIABLES);
-         LhsVar(3) = Rhs+3;
-       }
-       PutLhsVar();
-       return 0;
+         /* Return empty name */
+         createSingleString(pvApiCtx, Rhs + 1, "\0");
+         LhsVar(1) = Rhs + 1;
+         if (Lhs >= 2)
+         {
+             /* Return empty value */
+             createEmptyMatrix(pvApiCtx, Rhs + 2);
+             LhsVar(2) = Rhs + 2;
+         }
+         if (Lhs == 3)
+         {
+             /* Return error flag instead of variable class */
+             createScalarDouble(pvApiCtx, Rhs + 3, NO_MORE_VARIABLES);
+             LhsVar(3) = Rhs + 3;
+         }
+         PutLhsVar();
+         return TRUE;
      }
  
-   /* To be sure isComplex is 0 or 1 */
-   matvar->isComplex =  matvar->isComplex != 0;
+     /* To be sure isComplex is 0 or 1 */
+     matvar->isComplex =  matvar->isComplex != 0;
  
-   /* Return the variable name */
-   createSingleString(pvApiCtx, Rhs+1, matvar->name);
-   LhsVar(1) = Rhs+1;
+     /* Return the variable name */
+     createSingleString(pvApiCtx, Rhs + 1, matvar->name);
+     LhsVar(1) = Rhs + 1;
  
-   returnedClass = matvar->class_type;
+     returnedClass = matvar->class_type;
  
-   if (Lhs >= 2)
+     if (Lhs >= 2)
      {
-       /* Return the values */
-       if (!CreateMatlabVariable(pvApiCtx, Rhs+2, matvar, NULL, -1)) /* Could not Create Variable */
-       {
-         sciprint("Do not know how to read a variable of class %d.\n", matvar->class_type);
-         returnedClass = UNKNOWN_VARIABLE_TYPE;
-       }
-       LhsVar(2) = Rhs+2;
+         /* Return the values */
+         if (!CreateMatlabVariable(pvApiCtx, Rhs + 2, matvar, NULL, -1)) /* Could not Create Variable */
+         {
+             sciprint("Do not know how to read a variable of class %d.\n", matvar->class_type);
+             returnedClass = UNKNOWN_VARIABLE_TYPE;
+         }
+         LhsVar(2) = Rhs + 2;
      }
  
-   if (Lhs == 3)
+     if (Lhs == 3)
      {
-       /* Create class return value */
-       createScalarDouble(pvApiCtx, Rhs+3, returnedClass);
-       LhsVar(3) = Rhs+3;
+         /* Create class return value */
+         createScalarDouble(pvApiCtx, Rhs + 3, returnedClass);
+         LhsVar(3) = Rhs + 3;
      }
  
-   Mat_VarFree(matvar);
-   PutLhsVar();
-   return TRUE;
+     Mat_VarFree(matvar);
+     PutLhsVar();
+     return TRUE;
  }
  #include "GetMatlabVariable.h"
  #include "api_scilab.h"
  
- #define MATIO_ERROR if(_SciErr.iErr)       \
-     {                                      \
-       printError(&_SciErr, 0);                     \
-       return 1;                                    \
-     }
- enum matfile_errors {
-   NO_MORE_VARIABLES = -1,
-   UNKNOWN_VARIABLE_TYPE = 0
+ enum matfile_errors
+ {
+     NO_MORE_VARIABLES = -1,
+     UNKNOWN_VARIABLE_TYPE = 0
  };
  
- int sci_matfile_varwrite(char* fname, void* pvApiCtx)
 -int sci_matfile_varwrite(char *fname, unsigned long fname_len)
++int sci_matfile_varwrite(char *fname, void* pvApiCtx)
  {
-   int nbRow = 0, nbCol = 0;
-   mat_t *matfile = NULL;
-   matvar_t *matvar = NULL;
-   int fileIndex = 0;
-   char *varname = NULL;
-   int flag = 0;
-   int compressionFlag = 0;
-   int var_type;
-   int * fd_addr = NULL, * name_addr = NULL, * cp_flag_addr = NULL;
-   double tmp_dbl;
-   SciErr _SciErr;
-   CheckRhs(4, 4);
-   CheckLhs(1, 1);
-   /* Input argument is the index of the file to write */
-   _SciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr); MATIO_ERROR;
-   _SciErr = getVarType(pvApiCtx, fd_addr, &var_type); MATIO_ERROR;
-   if (var_type == sci_matrix)
+     int nbRow = 0, nbCol = 0;
+     mat_t *matfile = NULL;
+     matvar_t *matvar = NULL;
+     int fileIndex = 0;
+     char *varname = NULL;
+     int flag = 0;
+     int compressionFlag = 0;
+     int var_type;
+     int * fd_addr = NULL, * name_addr = NULL, * cp_flag_addr = NULL;
+     double tmp_dbl;
+     SciErr sciErr;
+     CheckRhs(4, 4);
+     CheckLhs(1, 1);
+     /* Input argument is the index of the file to write */
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &fd_addr);
+     if (sciErr.iErr)
      {
-       getScalarDouble(pvApiCtx, fd_addr, &tmp_dbl);
-       if (!isScalar(pvApiCtx, fd_addr))
-       {
-         Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
-         return 1;
-       }
-       fileIndex = (int)tmp_dbl;
+         printError(&sciErr, 0);
+         return 0;
      }
-   else
+     sciErr = getVarType(pvApiCtx, fd_addr, &var_type);
+     if (sciErr.iErr)
      {
-       Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
-       return 1;
+         printError(&sciErr, 0);
+         return 0;
      }
  
-   /* Gets the corresponding matfile */
-   matfile_manager(MATFILEMANAGER_GETFILE, &fileIndex, &matfile);
+     if (var_type == sci_matrix)
+     {
+         getScalarDouble(pvApiCtx, fd_addr, &tmp_dbl);
+         if (!isScalar(pvApiCtx, fd_addr))
+         {
+             Scierror(999, _("%s: Wrong size for first input argument: Single double expected.\n"), fname);
+             return FALSE;
+         }
+         fileIndex = (int)tmp_dbl;
+     }
+     else
+     {
+         Scierror(999, _("%s: Wrong type for first input argument: Double expected.\n"), fname);
+         return FALSE;
+     }
  
-   /* Second argument is the variable name */
+     /* Gets the corresponding matfile */
+     matfile_manager(MATFILEMANAGER_GETFILE, &fileIndex, &matfile);
  
-   _SciErr = getVarAddressFromPosition(pvApiCtx, 2, &name_addr); MATIO_ERROR;
-   _SciErr = getVarType(pvApiCtx, name_addr, &var_type); MATIO_ERROR;
+     /* Second argument is the variable name */
  
-   if (var_type == sci_strings)
+     sciErr = getVarAddressFromPosition(pvApiCtx, 2, &name_addr);
+     if (sciErr.iErr)
      {
-       getAllocatedSingleString(pvApiCtx, name_addr, &varname);
-       _SciErr = getVarDimension(pvApiCtx, name_addr, &nbRow, &nbCol); MATIO_ERROR;
-       if (nbCol != 1)
-       {
-         Scierror(999, _("%s: Wrong size for second input argument: Single string expected.\n"), fname);
-         freeAllocatedSingleString(varname);
+         printError(&sciErr, 0);
+         return 0;
+     }
+     sciErr = getVarType(pvApiCtx, name_addr, &var_type);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
  
-         return 1;
-       }
+     if (var_type == sci_strings)
+     {
+         getAllocatedSingleString(pvApiCtx, name_addr, &varname);
+         sciErr = getVarDimension(pvApiCtx, name_addr, &nbRow, &nbCol);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 0;
+         }
+         if (nbCol != 1)
+         {
+             Scierror(999, _("%s: Wrong size for second input argument: Single string expected.\n"), fname);
+             freeAllocatedSingleString(varname);
+             return FALSE;
+         }
      }
-   else
+     else
      {
-       Scierror(999, _("%s: Wrong type for second input argument: Single string expected.\n"), fname);
+         Scierror(999, _("%s: Wrong type for second input argument: Single string expected.\n"), fname);
  
-       freeAllocatedSingleString(varname);
+         freeAllocatedSingleString(varname);
  
-       return 1;
+         return FALSE;
      }
  
-   /* Third argument is the variable data */
-   matvar = GetMatlabVariable(pvApiCtx, 3, varname, matfile->version, NULL, -1);
+     /* Third argument is the variable data */
+     /* TODO update this NULL */
+     matvar = GetMatlabVariable(pvApiCtx, 3, varname, Mat_GetVersion(matfile), NULL, -1);
  
-   /* Fourth argument is the compression flag */
+     /* Fourth argument is the compression flag */
  
-   _SciErr = getVarAddressFromPosition(pvApiCtx, 4, &cp_flag_addr); MATIO_ERROR;
-   _SciErr = getVarType(pvApiCtx, cp_flag_addr, &var_type); MATIO_ERROR;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 4, &cp_flag_addr);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
+     sciErr = getVarType(pvApiCtx, cp_flag_addr, &var_type);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
  
-   if (var_type == sci_boolean)
+     if (var_type == sci_boolean)
      {
-       getScalarBoolean(pvApiCtx, cp_flag_addr, &compressionFlag);
-       if (!isScalar(pvApiCtx, cp_flag_addr))
-       {
-         Scierror(999, _("%s: Wrong size for fourth input argument: Single boolean expected.\n"), fname);
+         getScalarBoolean(pvApiCtx, cp_flag_addr, &compressionFlag);
+         if (!isScalar(pvApiCtx, cp_flag_addr))
+         {
+             Scierror(999, _("%s: Wrong size for fourth input argument: Single boolean expected.\n"), fname);
  
-         freeAllocatedSingleString(varname);
+             freeAllocatedSingleString(varname);
  
-         return 1;
-       }
+             return FALSE;
+         }
      }
-   else
+     else
      {
-       Scierror(999, _("%s: Wrong type for fourth input argument: Single boolean expected.\n"), fname);
+         Scierror(999, _("%s: Wrong type for fourth input argument: Single boolean expected.\n"), fname);
  
-       freeAllocatedSingleString(varname);
+         freeAllocatedSingleString(varname);
  
-       return 1;
+         return FALSE;
      }
  
-   flag = Mat_VarWrite(matfile, matvar, compressionFlag);
+     flag = Mat_VarWrite(matfile, matvar, compressionFlag);
  
-   /* Return execution flag */
-   var_type = (flag==0);
-   createScalarBoolean(pvApiCtx, Rhs+1, var_type);
+     /* Return execution flag */
+     var_type = (flag == 0);
+     createScalarBoolean(pvApiCtx, Rhs + 1, var_type);
  
-   freeAllocatedSingleString(varname);
-   LhsVar(1) = Rhs+1;
-   PutLhsVar();
+     freeAllocatedSingleString(varname);
+     LhsVar(1) = Rhs + 1;
+     PutLhsVar();
  
-   return TRUE;
+     return TRUE;
  }
  #include "Scierror.h"
  #include "sciprint.h"
  
- #define MATIO_ERROR if(_SciErr.iErr) \
-     {                              \
-       printError(&_SciErr, 0);             \
-       return 0;                            \
-     }
- int CreateBooleanVariable(void* pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
+ int CreateBooleanVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
  {
-   int nbRow = 0, nbCol = 0;
-   int * intPtr = NULL;
-   double * dblPtr = NULL;
-   int K = 0;
-   SciErr _SciErr;
+     int nbRow = 0, nbCol = 0;
+     int *piDims = NULL;
+     int * intPtr = NULL;
+     double * dblPtr = NULL;
+     int K = 0;
+     SciErr sciErr;
  
-   if (matVariable->rank==2) /* 2-D array */
+     if (matVariable->rank == 2) /* 2-D array */
      {
-       nbRow = matVariable->dims[0];
-       nbCol = matVariable->dims[1];
-       
-       if (nbRow*nbCol != 0)
+         nbRow = (int)matVariable->dims[0];
+         nbCol = (int)matVariable->dims[1];
+         if (nbRow * nbCol != 0)
          {
-           if ((intPtr = (int*) MALLOC(sizeof(int) * nbRow * nbCol)) == NULL)
+             if ((intPtr = (int*) MALLOC(sizeof(int) * nbRow * nbCol)) == NULL)
+             {
+                 Scierror(999, _("%s: No more memory.\n"), "CreateBooleanVariable");
+                 return FALSE;
+             }
+             for (K = 0; K < nbRow * nbCol; K++)
+             {
+                 intPtr[K] = ((unsigned char*)matVariable->data)[K];
+             }
+             if (parent == NULL)
              {
-               Scierror(999, _("%s: No more memory.\n"), "CreateBooleanVariable");
-               return FALSE;
+                 sciErr = createMatrixOfBoolean(pvApiCtx, iVar, nbRow, nbCol, intPtr);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
              }
-           
-           for (K = 0; K < nbRow*nbCol; K++)
+             else
              {
-               intPtr[K] = ((unsigned char*)matVariable->data)[K];
+                 sciErr = createMatrixOfBooleanInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, intPtr);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
              }
  
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfBoolean(pvApiCtx, iVar, nbRow, nbCol, intPtr); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfBooleanInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, intPtr); MATIO_ERROR;
-           }
-           
-           FREE(intPtr);
+             FREE(intPtr);
          }
-       else
+         else
          {
-           if ((dblPtr = (double *)MALLOC(sizeof(double) * nbRow * nbCol)) == NULL)
+             if ((dblPtr = (double *)MALLOC(sizeof(double) * nbRow * nbCol)) == NULL)
              {
-               Scierror(999, _("%s: No more memory.\n"), "CreateBooleanVariable");
-               return FALSE;
+                 Scierror(999, _("%s: No more memory.\n"), "CreateBooleanVariable");
+                 return FALSE;
              }
-           
-           for (K = 0; K < nbRow*nbCol; K++)
+             for (K = 0; K < nbRow * nbCol; K++)
              {
-               dblPtr[K] = ((unsigned char*)matVariable->data)[K];
+                 dblPtr[K] = ((unsigned char*)matVariable->data)[K];
              }
  
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, dblPtr);
-           }
-         else
-           {
-             _SciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, dblPtr);
-           }
+             if (parent == NULL)
+             {
+                 sciErr = createMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, dblPtr);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+             }
+             else
+             {
+                 sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, dblPtr);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+             }
  
-           FREE(dblPtr);
+             FREE(dblPtr);
          }
      }
-   else /* Multi-dimension array -> Scilab HyperMatrix */
+     else /* Multi-dimension array -> Scilab HyperMatrix */
      {
-       //CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_BOOLEAN_DATATYPE,  NULL, &matVariable->rank, matVariable->dims, matVariable->data, NULL, parent, item_position);
+         piDims = (int*) MALLOC(matVariable->rank * sizeof(int));
+         if (piDims == NULL)
+         {
+             Scierror(999, _("%s: No more memory.\n"), "CreateBooleanVariable");
+             return FALSE;
+         }
+         for (K = 0; K < matVariable->rank; K++)
+         {
+             piDims[K] = (int)matVariable->dims[K];
+         }
 -        CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_BOOLEAN_DATATYPE,  NULL, &matVariable->rank, piDims, (double*)matVariable->data, NULL, parent, item_position);
++        //CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_BOOLEAN_DATATYPE,  NULL, &matVariable->rank, piDims, (double*)matVariable->data, NULL, parent, item_position);
+         FREE(piDims);
      }
-   
-   return TRUE;
+     return TRUE;
  }
  
@@@ -60,14 -78,14 +78,14 @@@ int CreateCellVariable(void *pvApiCtx, 
      }
      else /* 3 or more dimensions -> Scilab HyperMatrix */
      {
-         /*
--        type = I_INT32;
--        CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,
-                       &type, &matVariable->rank, matVariable->dims, matVariable->data,
-                       NULL, cell_addr, 2);
-                 */
 -                                  &type, &matVariable->rank, piDims, (double*)matVariable->data,
 -                                  NULL, cell_addr, 2);
++        //type = I_INT32;
++        //CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,
++        //                          &type, &matVariable->rank, piDims, (double*)matVariable->data,
++        //                          NULL, cell_addr, 2);
      }
  
+     FREE(piDims);
      /* ALL OTHER ENTRIES: Fields data */
      prodDims = 1;
      for (K = 0; K < matVariable->rank; K++)
  #include "localization.h"
  #include "Scierror.h"
  
- #define MATIO_ERROR if(_SciErr.iErr)       \
-     {                                      \
-       printError(&_SciErr, 0);                     \
-       return 0;                                    \
-     }
- int CreateCharVariable(void* pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
+ int CreateCharVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
  {
-   int nbRow = 0, nbCol = 0;
-   char **charData = NULL;
-   int K = 0, L = 0;
-   SciErr _SciErr;
+     int nbRow = 0, nbCol = 0;
+     char **charData = NULL;
+     int K = 0, L = 0;
+     SciErr sciErr;
  
-   if(matVariable->rank==2) /* 2-D array */
+     if (matVariable->rank == 2) /* 2-D array */
      {
-       nbRow = matVariable->dims[0];
-       nbCol = nbRow==0 ? 0 : 1; /* In Scilab empty string has size 0x0 */
+         nbRow = (int)matVariable->dims[0];
+         nbCol = nbRow == 0 ? 0 : 1; /* In Scilab empty string has size 0x0 */
  
-       if (nbRow != 0)
-       {
-         charData =  (char**) MALLOC(sizeof(char*) * nbRow);
-         if (charData==NULL)
-           {
-             Scierror(999, _("%s: No more memory.\n"), "CreateCharVariable");
-             return FALSE;
-           }
-       }
+         if (nbRow != 0)
+         {
+             charData =  (char**) MALLOC(sizeof(char*) * nbRow);
+             if (charData == NULL)
+             {
+                 Scierror(999, _("%s: No more memory.\n"), "CreateCharVariable");
+                 return FALSE;
+             }
+         }
  
-       for (K=0; K<nbRow; K++)
-       {
-         charData[K] =  (char*) MALLOC(sizeof(char*) * (matVariable->dims[1] + 1));
-         if (charData[K]==NULL)
-           {
-             Scierror(999, _("%s: No more memory.\n"), "CreateCharVariable");
-             return FALSE;
-           }
-       }
+         for (K = 0; K < nbRow; K++)
+         {
+             charData[K] =  (char*) MALLOC(sizeof(char*) * (matVariable->dims[1] + 1));
+             if (charData[K] == NULL)
+             {
+                 Scierror(999, _("%s: No more memory.\n"), "CreateCharVariable");
+                 return FALSE;
+             }
+         }
  
-       /* Fill items: data in Matlab file is stored columnwise */
-       for(K=0; K<matVariable->dims[0]; K++) /* Loop over items */
-       {
-         for(L=0; L<matVariable->dims[1]; L++) /* Loop over chars */
-           {
-             if (matVariable->fp->version != MAT_FT_MAT4) /* MAT_FT_MAT4 format ==> data is a char* pointer */
-               {
-                 charData[K][L] = ((char *)matVariable->data)[L*matVariable->dims[0]+K];
-               }
-             else /* MAT_FT_MAT4 format ==> data is a double* pointer */
-               {
-                 charData[K][L] = (char) ((double *)matVariable->data)[L*matVariable->dims[0]+K];
-               }
-           }
-         charData[K][L] = '\0';
-       }
+         /* Fill items: data in Matlab file is stored columnwise */
+         for (K = 0; K < (int)matVariable->dims[0]; K++) /* Loop over items */
+         {
+             for (L = 0; L < (int)matVariable->dims[1]; L++) /* Loop over chars */
+             {
+                 charData[K][L] = ((char *)matVariable->data)[L * matVariable->dims[0] + K];
+             }
+             charData[K][L] = '\0';
+         }
  
-       if (nbRow*nbCol != 0)
-       {
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfString(pvApiCtx, iVar, nbRow, nbCol, charData); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfStringInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, charData); MATIO_ERROR;
-           }
-       }
-       else /* Empty character string */
-       {
-         if (parent==NULL)
-           {
-             createSingleString(pvApiCtx, iVar, "\0");
-           }
-         else
-           {
-             char ** tmp_char = (char **)MALLOC(sizeof(char *));
-             tmp_char[0] = os_strdup("\0");
-             _SciErr = createMatrixOfStringInList(pvApiCtx, iVar, parent, item_position, 1, 1, tmp_char); MATIO_ERROR;
-             freeArrayOfString(tmp_char, 1);
-           }
-       }
+         if (nbRow * nbCol != 0)
+         {
+             if (parent == NULL)
+             {
+                 sciErr = createMatrixOfString(pvApiCtx, iVar, nbRow, nbCol, charData);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+             }
+             else
+             {
+                 sciErr = createMatrixOfStringInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, charData);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+             }
+         }
+         else /* Empty character string */
+         {
+             if (parent == NULL)
+             {
+                 createSingleString(pvApiCtx, iVar, "\0");
+             }
+             else
+             {
+                 char ** tmp_char = (char **)MALLOC(sizeof(char *));
 -                tmp_char[0] = strdup("\0");
++                tmp_char[0] = os_strdup("\0");
+                 sciErr = createMatrixOfStringInList(pvApiCtx, iVar, parent, item_position, 1, 1, tmp_char);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 freeArrayOfString(tmp_char, 1);
+             }
+         }
  
-       freeArrayOfString(charData,nbRow*nbCol);
+         freeArrayOfString(charData, nbRow * nbCol);
      }
-   else /* Multi-dimension array -> Scilab HyperMatrix */
+     else /* Multi-dimension array -> Scilab HyperMatrix */
      {
-       Scierror(999, _("%s: N-D arrays of chars not implemented.\n"), "CreateCharVariable");
-       return FALSE;
+         Scierror(999, _("%s: N-D arrays of chars not implemented.\n"), "CreateCharVariable");
+         return FALSE;
      }
  
-   return TRUE;
+     return TRUE;
  }
  
  #include "CreateMatlabVariable.h"
  #include "api_scilab.h"
+ #include "MALLOC.h"
  
- #define MATIO_ERROR if(_SciErr.iErr) \
-     {                              \
-       printError(&_SciErr, 0);             \
-       return 0;                            \
-     }
- int CreateDoubleVariable(void* pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
+ int CreateDoubleVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
  {
-   int nbRow = 0, nbCol = 0;
-   struct ComplexSplit *mat5ComplexData = NULL;
-   SciErr _SciErr;
+     int nbRow = 0, nbCol = 0;
+     mat_complex_split_t *mat5ComplexData = NULL;
+     SciErr sciErr;
+     int *piDims = NULL;
+     int i = 0;
  
-   if(matVariable->rank==2) /* 2-D array */
+     if (matVariable->rank == 2) /* 2-D array */
      {
-       nbRow = matVariable->dims[0];
-       nbCol = matVariable->dims[1];
-       if (matVariable->isComplex == 0)
+         nbRow = (int)matVariable->dims[0];
+         nbCol = (int)matVariable->dims[1];
+         if (matVariable->isComplex == 0)
          {
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, (const double*)matVariable->data); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, (const double*)matVariable->data); MATIO_ERROR;
-           }
+             if (parent == NULL)
+             {
+                 sciErr = createMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, (double*)matVariable->data);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+             }
+             else
+             {
+                 sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, (double*)matVariable->data);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+             }
          }
-       else
+         else
          {
-           /* Since MATIO 1.3.2 data is a ComplexSplit for MAT4 and MAT5 formats */
-           mat5ComplexData = matVariable->data;
-         if (parent==NULL)
-           {
-             _SciErr = createComplexMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, (const double*)mat5ComplexData->Re, (const double*)mat5ComplexData->Im);
-           }
-         else
-           {
-             _SciErr = createComplexMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, 
-                                                         (const double*)mat5ComplexData->Re, (const double*)mat5ComplexData->Im);
-           }
+             /* Since MATIO 1.3.2 data is a ComplexSplit for MAT4 and MAT5 formats */
+             mat5ComplexData = matVariable->data;
+             if (parent == NULL)
+             {
+                 sciErr = createComplexMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, (double*)mat5ComplexData->Re, (double*)mat5ComplexData->Im);
+             }
+             else
+             {
+                 sciErr = createComplexMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol,
+                          (double*)mat5ComplexData->Re, (double*)mat5ComplexData->Im);
+             }
          }
      }
-   else /* Multi-dimension array -> Scilab HyperMatrix */
+     else /* Multi-dimension array -> Scilab HyperMatrix */
      {
-       if (matVariable->isComplex == 0)
+         piDims = (int *) MALLOC(matVariable->rank * sizeof(int));
+         for (i = 0 ; i < matVariable->rank ; ++i)
          {
- /*          CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_DOUBLE_DATATYPE, &matVariable->isComplex, &matVariable->rank, 
-                                   matVariable->dims, matVariable->data, NULL, parent, item_position);
- */        }
-       else
+             piDims[i] = (int)matVariable->dims[i];
+         }
+         if (matVariable->isComplex == 0)
          {
- /*          mat5ComplexData = matVariable->data;
-           CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_DOUBLE_DATATYPE, &matVariable->isComplex, &matVariable->rank, 
-                                   matVariable->dims, mat5ComplexData->Re, mat5ComplexData->Im, parent, item_position);
- */        }
 -            CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_DOUBLE_DATATYPE, &matVariable->isComplex, &matVariable->rank,
 -                                      piDims, (double*)matVariable->data, NULL, parent, item_position);
++            //CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_DOUBLE_DATATYPE, &matVariable->isComplex, &matVariable->rank,
++            //                          piDims, (double*)matVariable->data, NULL, parent, item_position);
+         }
+         else
+         {
 -            mat5ComplexData = (mat_complex_split_t*)matVariable->data;
 -            CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_DOUBLE_DATATYPE, &matVariable->isComplex, &matVariable->rank,
 -                                      piDims, (double*)mat5ComplexData->Re, (double*)mat5ComplexData->Im, parent, item_position);
++            //mat5ComplexData = (mat_complex_split_t*)matVariable->data;
++            //CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_DOUBLE_DATATYPE, &matVariable->isComplex, &matVariable->rank,
++            //                          piDims, (double*)mat5ComplexData->Re, (double*)mat5ComplexData->Im, parent, item_position);
+         }
+         FREE(piDims);
      }
-   return TRUE;
+     return TRUE;
  }
  #include "sciprint.h"
  
  
- int CreateHyperMatrixVariable(void* pvApiCtx, int iVar, const char *type, int *iscomplex, int * rank, int *dims, double *realdata, double *complexdata, int * parent, int item_position)
+ int CreateHyperMatrixVariable(void *pvApiCtx, int iVar, const char *type, int *iscomplex, int * rank, int *dims, double *realdata, double *complexdata, int * parent, int item_position)
  {
-     /*
-     **   !!!! In scilab6 HyperMatrix are no more Tlist !!!!
-     **   !!!! should rewrite this part using C++ API   !!!!
-     */
-     /*     static const char *tlistFields[] = {"hm", "dims","entries"}; */
-     /*     int nbRow = 0, nbCol = 0; */
-     /*     int K = 0, i; */
-     /*     int * hm_addr = NULL; */
-     /*     SciErr sciErr; */
-     /*     /\* Used for integer hypermatrices *\/ */
-     /*     char * tmp_int8 = NULL; */
-     /*     short * tmp_int16 = NULL; */
-     /*     int * tmp_int32 = NULL; */
-     /*     unsigned char * tmp_uint8 = NULL; */
-     /*     unsigned short * tmp_uint16 = NULL; */
-     /*     unsigned int * tmp_uint32 = NULL; */
-     /* #ifdef __SCILAB_INT64__ */
-     /*     long long * tmp_int64 = NULL; */
-     /*     unsigned long long * tmp_uint64 = NULL; */
-     /* #endif */
-     /*     if (parent==NULL) */
-     /*     { */
-     /*         sciErr = createMList(pvApiCtx, iVar, 3, &hm_addr); */
-     /*         if(sciErr.iErr) */
-     /*         { */
-     /*             printError(&sciErr, 0); */
-     /*             return FALSE; */
-     /*         } */
-     /*     } */
-     /*     else */
-     /*     { */
-     /*         sciErr = createMListInList(pvApiCtx, iVar, parent, item_position, 3, &hm_addr); */
-     /*         if(sciErr.iErr) */
-     /*         { */
-     /*             printError(&sciErr, 0); */
-     /*             return FALSE; */
-     /*         } */
-     /*     } */
-     /*     /\* mlist fields *\/ */
-     /*     nbRow = 1; */
-     /*     nbCol = 3; */
-     /*     sciErr = createMatrixOfStringInList(pvApiCtx, iVar, hm_addr, 1, nbRow, nbCol, (const char **)tlistFields); */
-     /*     if(sciErr.iErr) */
-     /*     { */
-     /*         printError(&sciErr, 0); */
-     /*         return FALSE; */
-     /*     } */
-     /*     /\* hm dimensions *\/ */
-     /*     sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, hm_addr, 2, 1, *rank, dims); */
-     /*     if(sciErr.iErr) */
-     /*     { */
-     /*         printError(&sciErr, 0); */
-     /*         return FALSE; */
-     /*     } */
-     /*     /\* hm entries *\/ */
-     /*     nbRow = 1; */
-     /*     nbCol = 1; */
-     /*     for (K=0; K<*rank; K++) */
-     /*     { */
-     /*         nbRow *= dims[K]; */
-     /*     } */
-     /*     if (strcmp(type,MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE) == 0) */
-     /*     { */
-     /*         switch(*iscomplex) */
-     /*         { */
-     /*             case I_CHAR: */
-     /*                 tmp_int8 = (char *)MALLOC(nbRow*nbCol*sizeof(char)); */
-     /*                 if (tmp_int8 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0; i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_int8[i] = ((char *)realdata)[i]; */
-     /*                 } */
-     /*                 sciErr = createMatrixOfInteger8InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int8); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_int8); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_int8); */
-     /*                 break; */
-     /*             case I_INT16: */
-     /*                 tmp_int16 = (short *)MALLOC(nbRow*nbCol*sizeof(short)); */
-     /*                 if (tmp_int16 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0; i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_int16[i] = ((short *)realdata)[i]; */
-     /*                 } */
-     /*                 sciErr = createMatrixOfInteger16InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int16); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_int16); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_int16); */
-     /*                 break; */
-     /*             case I_INT32: */
-     /*                 tmp_int32 = (int *)MALLOC(nbRow*nbCol*sizeof(int)); */
-     /*                 if (tmp_int32 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0; i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_int32[i] = ((int *)realdata)[i]; */
-     /*                 } */
-     /*                 sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int32); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_int32); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_int32); */
-     /*                 break; */
-     /* #ifdef __SCILAB_INT64__ */
-     /*             case I_INT64: */
-     /*                 tmp_int64 = (long long *)MALLOC(nbRow*nbCol*sizeof(long long)); */
-     /*                 if (tmp_int64 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0; i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_int64[i] = ((long long *)realdata)[i]; */
-     /*                 } */
-     /*                 qciErr = createMatrixOfInteger64InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int64); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_int64); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_int64); */
-     /*                 break; */
-     /* #endif */
-     /*             case I_UCHAR: */
-     /*                 tmp_uint8 = (unsigned char *)MALLOC(nbRow*nbCol*sizeof(unsigned char)); */
-     /*                 if (tmp_uint8 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0; i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_uint8[i] = ((unsigned char *)realdata)[i]; */
-     /*                 } */
-     /*                 sciErr = createMatrixOfUnsignedInteger8InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint8); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_uint8); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_uint8); */
-     /*                 break; */
-     /*             case I_UINT16: */
-     /*                 tmp_uint16 = (unsigned short *)MALLOC(nbRow*nbCol*sizeof(unsigned short)); */
-     /*                 if (tmp_uint16 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0; i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_uint16[i] = ((unsigned short *)realdata)[i]; */
-     /*                 } */
-     /*                 sciErr = createMatrixOfUnsignedInteger16InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint16); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_uint16); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_uint16); */
-     /*                 break; */
-     /*             case I_UINT32: */
-     /*                 tmp_uint32 = (unsigned int *)MALLOC(nbRow*nbCol*sizeof(unsigned int)); */
-     /*                 if (tmp_uint32 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0;i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_uint32[i] = ((unsigned int *)realdata)[i]; */
-     /*                 } */
-     /*                 sciErr = createMatrixOfUnsignedInteger32InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint32); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_uint32); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_uint32); */
-     /*                 break; */
-     /* #ifdef __SCILAB_INT64__ */
-     /*             case I_UINT64: */
-     /*                 tmp_uint64 = (unsigned long long *)MALLOC(nbRow*nbCol*sizeof(unsigned long long)); */
-     /*                 if (tmp_uint64 == NULL) */
-     /*                 { */
-     /*                     Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable"); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 for(i=0; i<nbRow*nbCol; i++) */
-     /*                 { */
-     /*                     tmp_uint64[i] = ((unsigned long long *)realdata)[i]; */
-     /*                 } */
-     /*                 sciErr = createMatrixOfUnsignedInteger64InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint64); */
-     /*                 if(sciErr.iErr) */
-     /*                 { */
-     /*                     printError(&sciErr, 0); */
-     /*                     FREE(tmp_uint64); */
-     /*                     return FALSE; */
-     /*                 } */
-     /*                 FREE(tmp_uint64); */
-     /*                 break; */
-     /* #endif */
-     /*         } */
-     /*     } */
-     /*     else if (strcmp(type, MATRIX_OF_BOOLEAN_DATATYPE) == 0) */
-     /*     { */
-     /*         sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata); */
-     /*         if(sciErr.iErr) */
-     /*         { */
-     /*             printError(&sciErr, 0); */
-     /*             return FALSE; */
-     /*         } */
-     /*     } */
-     /*     else */
-     /*     { */
-     /*         if (*iscomplex == 0) */
-     /*         { */
-     /*             sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata); */
-     /*             if(sciErr.iErr) */
-     /*             { */
-     /*                 printError(&sciErr, 0); */
-     /*                 return FALSE; */
-     /*             } */
-     /*         } */
-     /*         else */
-     /*         { */
-     /*             sciErr = createComplexMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata, complexdata); */
-     /*             if(sciErr.iErr) */
-     /*             { */
-     /*                 printError(&sciErr, 0); */
-     /*                 return FALSE; */
-     /*             } */
-     /*         } */
-     /*     } */
-     /*     return TRUE; */
 -    static const char *tlistFields[] = {"hm", "dims", "entries"};
 -    int nbRow = 0, nbCol = 0;
 -    int K = 0, i;
 -    int * hm_addr = NULL;
 -    SciErr sciErr;
 -
 -    /* Used for integer hypermatrices */
 -    char * tmp_int8 = NULL;
 -    short * tmp_int16 = NULL;
 -    int * tmp_int32 = NULL;
 -    unsigned char * tmp_uint8 = NULL;
 -    unsigned short * tmp_uint16 = NULL;
 -    unsigned int * tmp_uint32 = NULL;
 -#ifdef __SCILAB_INT64__
 -    long long * tmp_int64 = NULL;
 -    unsigned long long * tmp_uint64 = NULL;
 -#endif
 -
 -    if (parent == NULL)
 -    {
 -        sciErr = createMList(pvApiCtx, iVar, 3, &hm_addr);
 -        if (sciErr.iErr)
 -        {
 -            printError(&sciErr, 0);
 -            return FALSE;
 -        }
 -    }
 -    else
 -    {
 -        sciErr = createMListInList(pvApiCtx, iVar, parent, item_position, 3, &hm_addr);
 -        if (sciErr.iErr)
 -        {
 -            printError(&sciErr, 0);
 -            return FALSE;
 -        }
 -    }
 -
 -    /* mlist fields */
 -    nbRow = 1;
 -    nbCol = 3;
 -    sciErr = createMatrixOfStringInList(pvApiCtx, iVar, hm_addr, 1, nbRow, nbCol, (const char **)tlistFields);
 -    if (sciErr.iErr)
 -    {
 -        printError(&sciErr, 0);
 -        return FALSE;
 -    }
 -
 -    /* hm dimensions */
 -    sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, hm_addr, 2, 1, *rank, dims);
 -    if (sciErr.iErr)
 -    {
 -        printError(&sciErr, 0);
 -        return FALSE;
 -    }
 -
 -    /* hm entries */
 -    nbRow = 1;
 -    nbCol = 1;
 -    for (K = 0; K < *rank; K++)
 -    {
 -        nbRow *= dims[K];
 -    }
 -
 -    if (strcmp(type, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE) == 0)
 -    {
 -        switch (*iscomplex)
 -        {
 -            case I_CHAR:
 -                tmp_int8 = (char *)MALLOC(nbRow * nbCol * sizeof(char));
 -                if (tmp_int8 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_int8[i] = ((char *)realdata)[i];
 -                }
 -                sciErr = createMatrixOfInteger8InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int8);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_int8);
 -                    return FALSE;
 -                }
 -                FREE(tmp_int8);
 -                break;
 -            case I_INT16:
 -                tmp_int16 = (short *)MALLOC(nbRow * nbCol * sizeof(short));
 -                if (tmp_int16 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_int16[i] = ((short *)realdata)[i];
 -                }
 -                sciErr = createMatrixOfInteger16InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int16);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_int16);
 -                    return FALSE;
 -                }
 -
 -                FREE(tmp_int16);
 -                break;
 -            case I_INT32:
 -                tmp_int32 = (int *)MALLOC(nbRow * nbCol * sizeof(int));
 -                if (tmp_int32 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_int32[i] = ((int *)realdata)[i];
 -                }
 -                sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int32);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_int32);
 -                    return FALSE;
 -                }
 -                FREE(tmp_int32);
 -                break;
 -#ifdef __SCILAB_INT64__
 -            case I_INT64:
 -                tmp_int64 = (long long *)MALLOC(nbRow * nbCol * sizeof(long long));
 -                if (tmp_int64 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_int64[i] = ((long long *)realdata)[i];
 -                }
 -                qciErr = createMatrixOfInteger64InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int64);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_int64);
 -                    return FALSE;
 -                }
 -                FREE(tmp_int64);
 -                break;
 -#endif
 -            case I_UCHAR:
 -                tmp_uint8 = (unsigned char *)MALLOC(nbRow * nbCol * sizeof(unsigned char));
 -                if (tmp_uint8 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_uint8[i] = ((unsigned char *)realdata)[i];
 -                }
 -                sciErr = createMatrixOfUnsignedInteger8InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint8);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_uint8);
 -                    return FALSE;
 -                }
 -                FREE(tmp_uint8);
 -                break;
 -            case I_UINT16:
 -                tmp_uint16 = (unsigned short *)MALLOC(nbRow * nbCol * sizeof(unsigned short));
 -                if (tmp_uint16 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_uint16[i] = ((unsigned short *)realdata)[i];
 -                }
 -                sciErr = createMatrixOfUnsignedInteger16InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint16);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_uint16);
 -                    return FALSE;
 -                }
 -                FREE(tmp_uint16);
 -                break;
 -            case I_UINT32:
 -                tmp_uint32 = (unsigned int *)MALLOC(nbRow * nbCol * sizeof(unsigned int));
 -                if (tmp_uint32 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_uint32[i] = ((unsigned int *)realdata)[i];
 -                }
 -                sciErr = createMatrixOfUnsignedInteger32InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint32);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_uint32);
 -                    return FALSE;
 -                }
 -                FREE(tmp_uint32);
 -                break;
 -#ifdef __SCILAB_INT64__
 -            case I_UINT64:
 -                tmp_uint64 = (unsigned long long *)MALLOC(nbRow * nbCol * sizeof(unsigned long long));
 -                if (tmp_uint64 == NULL)
 -                {
 -                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
 -                    return FALSE;
 -                }
 -                for (i = 0; i < nbRow * nbCol; i++)
 -                {
 -                    tmp_uint64[i] = ((unsigned long long *)realdata)[i];
 -                }
 -                sciErr = createMatrixOfUnsignedInteger64InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint64);
 -                if (sciErr.iErr)
 -                {
 -                    printError(&sciErr, 0);
 -                    FREE(tmp_uint64);
 -                    return FALSE;
 -                }
 -                FREE(tmp_uint64);
 -                break;
 -#endif
 -        }
 -    }
 -    else if (strcmp(type, MATRIX_OF_BOOLEAN_DATATYPE) == 0)
 -    {
 -        sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata);
 -        if (sciErr.iErr)
 -        {
 -            printError(&sciErr, 0);
 -            return FALSE;
 -        }
 -    }
 -    else
 -    {
 -        if (*iscomplex == 0)
 -        {
 -            sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata);
 -            if (sciErr.iErr)
 -            {
 -                printError(&sciErr, 0);
 -                return FALSE;
 -            }
 -        }
 -        else
 -        {
 -            sciErr = createComplexMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata, complexdata);
 -            if (sciErr.iErr)
 -            {
 -                printError(&sciErr, 0);
 -                return FALSE;
 -            }
 -        }
 -    }
 -
 -    return TRUE;
++//    static const char *tlistFields[] = {"hm", "dims", "entries"};
++//    int nbRow = 0, nbCol = 0;
++//    int K = 0, i;
++//    int * hm_addr = NULL;
++//    SciErr sciErr;
++//
++//    /* Used for integer hypermatrices */
++//    char * tmp_int8 = NULL;
++//    short * tmp_int16 = NULL;
++//    int * tmp_int32 = NULL;
++//    unsigned char * tmp_uint8 = NULL;
++//    unsigned short * tmp_uint16 = NULL;
++//    unsigned int * tmp_uint32 = NULL;
++//#ifdef __SCILAB_INT64__
++//    long long * tmp_int64 = NULL;
++//    unsigned long long * tmp_uint64 = NULL;
++//#endif
++//
++//    if (parent == NULL)
++//    {
++//        sciErr = createMList(pvApiCtx, iVar, 3, &hm_addr);
++//        if (sciErr.iErr)
++//        {
++//            printError(&sciErr, 0);
++//            return FALSE;
++//        }
++//    }
++//    else
++//    {
++//        sciErr = createMListInList(pvApiCtx, iVar, parent, item_position, 3, &hm_addr);
++//        if (sciErr.iErr)
++//        {
++//            printError(&sciErr, 0);
++//            return FALSE;
++//        }
++//    }
++//
++//    /* mlist fields */
++//    nbRow = 1;
++//    nbCol = 3;
++//    sciErr = createMatrixOfStringInList(pvApiCtx, iVar, hm_addr, 1, nbRow, nbCol, (const char **)tlistFields);
++//    if (sciErr.iErr)
++//    {
++//        printError(&sciErr, 0);
++//        return FALSE;
++//    }
++//
++//    /* hm dimensions */
++//    sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, hm_addr, 2, 1, *rank, dims);
++//    if (sciErr.iErr)
++//    {
++//        printError(&sciErr, 0);
++//        return FALSE;
++//    }
++//
++//    /* hm entries */
++//    nbRow = 1;
++//    nbCol = 1;
++//    for (K = 0; K < *rank; K++)
++//    {
++//        nbRow *= dims[K];
++//    }
++//
++//    if (strcmp(type, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE) == 0)
++//    {
++//        switch (*iscomplex)
++//        {
++//            case I_CHAR:
++//                tmp_int8 = (char *)MALLOC(nbRow * nbCol * sizeof(char));
++//                if (tmp_int8 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_int8[i] = ((char *)realdata)[i];
++//                }
++//                sciErr = createMatrixOfInteger8InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int8);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_int8);
++//                    return FALSE;
++//                }
++//                FREE(tmp_int8);
++//                break;
++//            case I_INT16:
++//                tmp_int16 = (short *)MALLOC(nbRow * nbCol * sizeof(short));
++//                if (tmp_int16 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_int16[i] = ((short *)realdata)[i];
++//                }
++//                sciErr = createMatrixOfInteger16InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int16);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_int16);
++//                    return FALSE;
++//                }
++//
++//                FREE(tmp_int16);
++//                break;
++//            case I_INT32:
++//                tmp_int32 = (int *)MALLOC(nbRow * nbCol * sizeof(int));
++//                if (tmp_int32 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_int32[i] = ((int *)realdata)[i];
++//                }
++//                sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int32);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_int32);
++//                    return FALSE;
++//                }
++//                FREE(tmp_int32);
++//                break;
++//#ifdef __SCILAB_INT64__
++//            case I_INT64:
++//                tmp_int64 = (long long *)MALLOC(nbRow * nbCol * sizeof(long long));
++//                if (tmp_int64 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_int64[i] = ((long long *)realdata)[i];
++//                }
++//                qciErr = createMatrixOfInteger64InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_int64);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_int64);
++//                    return FALSE;
++//                }
++//                FREE(tmp_int64);
++//                break;
++//#endif
++//            case I_UCHAR:
++//                tmp_uint8 = (unsigned char *)MALLOC(nbRow * nbCol * sizeof(unsigned char));
++//                if (tmp_uint8 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_uint8[i] = ((unsigned char *)realdata)[i];
++//                }
++//                sciErr = createMatrixOfUnsignedInteger8InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint8);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_uint8);
++//                    return FALSE;
++//                }
++//                FREE(tmp_uint8);
++//                break;
++//            case I_UINT16:
++//                tmp_uint16 = (unsigned short *)MALLOC(nbRow * nbCol * sizeof(unsigned short));
++//                if (tmp_uint16 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_uint16[i] = ((unsigned short *)realdata)[i];
++//                }
++//                sciErr = createMatrixOfUnsignedInteger16InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint16);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_uint16);
++//                    return FALSE;
++//                }
++//                FREE(tmp_uint16);
++//                break;
++//            case I_UINT32:
++//                tmp_uint32 = (unsigned int *)MALLOC(nbRow * nbCol * sizeof(unsigned int));
++//                if (tmp_uint32 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_uint32[i] = ((unsigned int *)realdata)[i];
++//                }
++//                sciErr = createMatrixOfUnsignedInteger32InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint32);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_uint32);
++//                    return FALSE;
++//                }
++//                FREE(tmp_uint32);
++//                break;
++//#ifdef __SCILAB_INT64__
++//            case I_UINT64:
++//                tmp_uint64 = (unsigned long long *)MALLOC(nbRow * nbCol * sizeof(unsigned long long));
++//                if (tmp_uint64 == NULL)
++//                {
++//                    Scierror(999, _("%s: No more memory.\n"), "CreateHyperMatrixVariable");
++//                    return FALSE;
++//                }
++//                for (i = 0; i < nbRow * nbCol; i++)
++//                {
++//                    tmp_uint64[i] = ((unsigned long long *)realdata)[i];
++//                }
++//                sciErr = createMatrixOfUnsignedInteger64InList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, tmp_uint64);
++//                if (sciErr.iErr)
++//                {
++//                    printError(&sciErr, 0);
++//                    FREE(tmp_uint64);
++//                    return FALSE;
++//                }
++//                FREE(tmp_uint64);
++//                break;
++//#endif
++//        }
++//    }
++//    else if (strcmp(type, MATRIX_OF_BOOLEAN_DATATYPE) == 0)
++//    {
++//        sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata);
++//        if (sciErr.iErr)
++//        {
++//            printError(&sciErr, 0);
++//            return FALSE;
++//        }
++//    }
++//    else
++//    {
++//        if (*iscomplex == 0)
++//        {
++//            sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata);
++//            if (sciErr.iErr)
++//            {
++//                printError(&sciErr, 0);
++//                return FALSE;
++//            }
++//        }
++//        else
++//        {
++//            sciErr = createComplexMatrixOfDoubleInList(pvApiCtx, iVar, hm_addr, 3, nbRow, nbCol, realdata, complexdata);
++//            if (sciErr.iErr)
++//            {
++//                printError(&sciErr, 0);
++//                return FALSE;
++//            }
++//        }
++//    }
++//
++//    return TRUE;
 +    return FALSE;
  }
++
  #include "Scierror.h"
  #include "sciprint.h"
  
- #define MATIO_ERROR if(_SciErr.iErr) \
-     {                              \
-       printError(&_SciErr, 0);             \
-       return 0;                            \
-     }
- int CreateIntegerVariable(void* pvApiCtx, int iVar, int integerType, matvar_t *matVariable, int * parent, int item_position)
+ int CreateIntegerVariable(void *pvApiCtx, int iVar, int integerType, matvar_t *matVariable, int * parent, int item_position)
  {
-   int nbRow, nbCol, i;
-   SciErr _SciErr;
-   char * tmp_int8 = NULL;
-   short * tmp_int16 = NULL;
-   int * tmp_int32 = NULL;
-   unsigned char * tmp_uint8 = NULL;
-   unsigned short * tmp_uint16 = NULL;
-   unsigned int * tmp_uint32 = NULL;
+     int nbRow, nbCol, i;
+     SciErr sciErr;
+     char * tmp_int8 = NULL;
+     short * tmp_int16 = NULL;
+     int * tmp_int32 = NULL;
+     int *piDims = NULL;
+     unsigned char * tmp_uint8 = NULL;
+     unsigned short * tmp_uint16 = NULL;
+     unsigned int * tmp_uint32 = NULL;
  #ifdef __SCILAB_INT64__
-   long long * tmp_int64 = NULL;
-   unsigned long long * tmp_uint64 = NULL;
+     long long * tmp_int64 = NULL;
+     unsigned long long * tmp_uint64 = NULL;
  #endif
  
-   // Matrix dimensions
-   nbRow = matVariable->dims[0];
-   nbCol = matVariable->dims[1];
+     // Matrix dimensions
+     nbRow = (int)matVariable->dims[0];
+     nbCol = (int)matVariable->dims[1];
  
-   if (matVariable->rank==2) /* 2-D array */
+     if (matVariable->rank == 2) /* 2-D array */
      {
-       switch(integerType)
-       {
-       case SCI_INT8:
-         tmp_int8 = (char *)MALLOC(nbRow*nbCol*sizeof(char));
-         if (tmp_int8 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_int8[i] = ((char *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfInteger8(pvApiCtx, iVar, nbRow, nbCol, tmp_int8); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfInteger8InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int8); MATIO_ERROR;
-           }
-         FREE(tmp_int8);
-         break;
-       case SCI_INT16:
-         tmp_int16 = (short *)MALLOC(nbRow*nbCol*sizeof(short));
-         if (tmp_int16 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_int16[i] = ((short *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfInteger16(pvApiCtx, iVar, nbRow, nbCol, tmp_int16); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfInteger16InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int16); MATIO_ERROR;
-           }
-         FREE(tmp_int16);
-         break;
-       case SCI_INT32:
-         tmp_int32 = (int *)MALLOC(nbRow*nbCol*sizeof(int));
-         if (tmp_int32 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_int32[i] = ((int *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfInteger32(pvApiCtx, iVar, nbRow, nbCol, tmp_int32); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int32); MATIO_ERROR;
-           }
-         FREE(tmp_int32);
-         break;
+         switch (integerType)
+         {
 -            case I_CHAR:
++            case SCI_INT8:
+                 tmp_int8 = (char *)MALLOC(nbRow * nbCol * sizeof(char));
+                 if (tmp_int8 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_int8[i] = ((char *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfInteger8(pvApiCtx, iVar, nbRow, nbCol, tmp_int8);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfInteger8InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int8);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_int8);
+                 break;
 -            case I_INT16:
++            case SCI_INT16:
+                 tmp_int16 = (short *)MALLOC(nbRow * nbCol * sizeof(short));
+                 if (tmp_int16 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_int16[i] = ((short *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfInteger16(pvApiCtx, iVar, nbRow, nbCol, tmp_int16);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfInteger16InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int16);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_int16);
+                 break;
 -            case I_INT32:
++            case SCI_INT32:
+                 tmp_int32 = (int *)MALLOC(nbRow * nbCol * sizeof(int));
+                 if (tmp_int32 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_int32[i] = ((int *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfInteger32(pvApiCtx, iVar, nbRow, nbCol, tmp_int32);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfInteger32InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int32);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_int32);
+                 break;
  #ifdef __SCILAB_INT64__
-       case SCI_INT64:
-         tmp_int64 = (long long *)MALLOC(nbRow*nbCol*sizeof(long long));
-         if (tmp_int64 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_int64[i] = ((long long *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfInteger64(pvApiCtx, iVar, nbRow, nbCol, tmp_int64); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfInteger64InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int64); MATIO_ERROR;
-           }
-         FREE(tmp_int64);
-         break;
 -            case I_INT64:
++            case SCI_INT64:
+                 tmp_int64 = (long long *)MALLOC(nbRow * nbCol * sizeof(long long));
+                 if (tmp_int64 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_int64[i] = ((long long *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfInteger64(pvApiCtx, iVar, nbRow, nbCol, tmp_int64);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfInteger64InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_int64);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_int64);
+                 break;
  #endif
-       case SCI_UINT8:
-         tmp_uint8 = (unsigned char *)MALLOC(nbRow*nbCol*sizeof(unsigned char));
-         if (tmp_uint8 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_uint8[i] = ((unsigned char *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfUnsignedInteger8(pvApiCtx, iVar, nbRow, nbCol, tmp_uint8); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfUnsignedInteger8InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint8); MATIO_ERROR;
-           }
-         FREE(tmp_uint8);
-         break;
-       case SCI_UINT16:
-         tmp_uint16 = (unsigned short *)MALLOC(nbRow*nbCol*sizeof(unsigned short));
-         if (tmp_uint16 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_uint16[i] = ((unsigned short *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfUnsignedInteger16(pvApiCtx, iVar, nbRow, nbCol, tmp_uint16); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfUnsignedInteger16InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint16); MATIO_ERROR;
-           }
-         FREE(tmp_uint16);
-         break;
-       case SCI_UINT32:
-         tmp_uint32 = (unsigned int *)MALLOC(nbRow*nbCol*sizeof(unsigned int));
-         if (tmp_uint32 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_uint32[i] = ((unsigned int *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfUnsignedInteger32(pvApiCtx, iVar, nbRow, nbCol, tmp_uint32); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfUnsignedInteger32InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint32); MATIO_ERROR;
-           }
-         FREE(tmp_uint32);
-         break;
 -            case I_UCHAR:
++            case SCI_UINT8 :
+                 tmp_uint8 = (unsigned char *)MALLOC(nbRow * nbCol * sizeof(unsigned char));
+                 if (tmp_uint8 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_uint8[i] = ((unsigned char *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfUnsignedInteger8(pvApiCtx, iVar, nbRow, nbCol, tmp_uint8);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfUnsignedInteger8InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint8);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_uint8);
+                 break;
 -            case I_UINT16:
++            case SCI_UINT16:
+                 tmp_uint16 = (unsigned short *)MALLOC(nbRow * nbCol * sizeof(unsigned short));
+                 if (tmp_uint16 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_uint16[i] = ((unsigned short *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfUnsignedInteger16(pvApiCtx, iVar, nbRow, nbCol, tmp_uint16);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfUnsignedInteger16InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint16);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_uint16);
+                 break;
 -            case I_UINT32:
++            case SCI_UINT32:
+                 tmp_uint32 = (unsigned int *)MALLOC(nbRow * nbCol * sizeof(unsigned int));
+                 if (tmp_uint32 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_uint32[i] = ((unsigned int *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfUnsignedInteger32(pvApiCtx, iVar, nbRow, nbCol, tmp_uint32);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfUnsignedInteger32InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint32);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_uint32);
+                 break;
  #ifdef __SCILAB_INT64__
-       case SCI_UINT64:
-         tmp_uint64 = (unsigned long long *)MALLOC(nbRow*nbCol*sizeof(unsigned long long));
-         if (tmp_uint64 == NULL)
-             {
-               Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
-               return FALSE;
-             }
-         for(i=0;i<nbRow*nbCol; i++) tmp_uint64[i] = ((unsigned long long *)matVariable->data)[i];
-         if (parent==NULL)
-           {
-             _SciErr = createMatrixOfUnsignedInteger64(pvApiCtx, iVar, nbRow, nbCol, tmp_uint64); MATIO_ERROR;
-           }
-         else
-           {
-             _SciErr = createMatrixOfUnsignedInteger64InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint64); MATIO_ERROR;
-           }
-         FREE(tmp_uint64);
-         break;
 -            case I_UINT64:
++            case SCI_UINT64:
+                 tmp_uint64 = (unsigned long long *)MALLOC(nbRow * nbCol * sizeof(unsigned long long));
+                 if (tmp_uint64 == NULL)
+                 {
+                     Scierror(999, _("%s: No more memory.\n"), "CreateIntegerVariable");
+                     return FALSE;
+                 }
+                 for (i = 0; i < nbRow * nbCol; i++)
+                 {
+                     tmp_uint64[i] = ((unsigned long long *)matVariable->data)[i];
+                 }
+                 if (parent == NULL)
+                 {
+                     sciErr = createMatrixOfUnsignedInteger64(pvApiCtx, iVar, nbRow, nbCol, tmp_uint64);
+                 }
+                 else
+                 {
+                     sciErr = createMatrixOfUnsignedInteger64InList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, tmp_uint64);
+                 }
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+                 FREE(tmp_uint64);
+                 break;
  #endif
-       }
+         }
      }
-   else /* Multi-dimension array -> Scilab HyperMatrix */
+     else /* Multi-dimension array -> Scilab HyperMatrix */
      {
- /*      CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,  &integerType, &matVariable->rank, 
-                               matVariable->dims, matVariable->data, NULL, parent, item_position);
- */    }
-   
-   return TRUE;
+         piDims = (int*) MALLOC(matVariable->rank * sizeof(int));
+         if (piDims == NULL)
+         {
+             Scierror(999, _("%s: No more memory.\n"), "CreateBooleanVariable");
+             return FALSE;
+         }
+         for (i = 0; i < matVariable->rank; i++)
+         {
+             piDims[i] = (int)matVariable->dims[i];
+         }
 -        CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,  &integerType, &matVariable->rank,
 -                                  piDims, (double*)matVariable->data, NULL, parent, item_position);
++        //CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,  &integerType, &matVariable->rank,
++        //                          piDims, (double*)matVariable->data, NULL, parent, item_position);
+         FREE(piDims);
+     }
+     return TRUE;
  }
  #include "CreateMatlabVariable.h"
  #include "api_scilab.h"
  
- int CreateMatlabVariable(void* pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
+ int CreateMatlabVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
  {
-   SciErr _SciErr;
+     SciErr sciErr;
  
-   /* To be sure isComplex is 0 or 1 */
-   matVariable->isComplex =  matVariable->isComplex != 0;
+     /* To be sure isComplex is 0 or 1 */
+     matVariable->isComplex =  matVariable->isComplex != 0;
  
-   switch(matVariable->class_type)
+     switch (matVariable->class_type)
      {
-     case MAT_C_CELL: /* 1 */
-       CreateCellVariable(pvApiCtx, iVar, matVariable, parent, item_position);
-       break;
-     case MAT_C_STRUCT: /* 2 */
-       CreateStructVariable(pvApiCtx, iVar, matVariable, parent, item_position);
-       break;
-     case MAT_C_CHAR: /* 4 */
-       CreateCharVariable(pvApiCtx, iVar, matVariable, parent, item_position);
-       break;
-     case MAT_C_SPARSE: /* 5 */
-       CreateSparseVariable(pvApiCtx, iVar, matVariable, parent, item_position);
-       break;
-     case MAT_C_DOUBLE: /* 6 */
-     case MAT_C_SINGLE: /* 7 */
-       CreateDoubleVariable(pvApiCtx, iVar, matVariable, parent, item_position);
-       break;
-     case MAT_C_INT8: /* 8 */
-       CreateIntegerVariable(pvApiCtx, iVar, SCI_INT8, matVariable, parent, item_position);
-       break;
-     case MAT_C_UINT8: /* 9 */
-       if (matVariable->isLogical != 0)
-         {
-           CreateBooleanVariable(pvApiCtx, iVar, matVariable, parent, item_position);
-         }
-       else
-         {
-           CreateIntegerVariable(pvApiCtx, iVar, SCI_UINT8, matVariable, parent, item_position);
-         }
-       break;
-     case MAT_C_INT16: /* 10 */
-       CreateIntegerVariable(pvApiCtx, iVar, SCI_INT16, matVariable, parent, item_position);
-       break;
-     case MAT_C_UINT16: /* 11 */
-       CreateIntegerVariable(pvApiCtx, iVar, SCI_UINT16, matVariable, parent, item_position);
-       break;
-     case MAT_C_INT32: /* 12 */
-       CreateIntegerVariable(pvApiCtx, iVar, SCI_INT32, matVariable, parent, item_position);
-       break;
-     case MAT_C_UINT32: /* 13 */
-       CreateIntegerVariable(pvApiCtx, iVar, SCI_UINT32, matVariable, parent, item_position);
-       break;
-     case MAT_C_OBJECT: /* 3 to be written */
-     case MAT_C_INT64: /* 14 */
-       CreateIntegerVariable(pvApiCtx, iVar, SCI_INT64, matVariable, parent, item_position);
-       break;
-     case MAT_C_UINT64: /* 15 */
-       CreateIntegerVariable(pvApiCtx, iVar, SCI_UINT64, matVariable, parent, item_position);
-       break;
-     case MAT_C_FUNCTION: /* 16 to be written */
-     default:
-       /* Empty matrix returned */
-       if (parent==NULL)
-       {
-         createEmptyMatrix(pvApiCtx, iVar);
-       }
-       else
-       {
-         _SciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, 0, 0, NULL);
-       }
-       return FALSE;
+         case MAT_C_CELL: /* 1 */
+             CreateCellVariable(pvApiCtx, iVar, matVariable, parent, item_position);
+             break;
+         case MAT_C_STRUCT: /* 2 */
+             CreateStructVariable(pvApiCtx, iVar, matVariable, parent, item_position);
+             break;
+         case MAT_C_CHAR: /* 4 */
+             CreateCharVariable(pvApiCtx, iVar, matVariable, parent, item_position);
+             break;
+         case MAT_C_SPARSE: /* 5 */
+             CreateSparseVariable(pvApiCtx, iVar, matVariable, parent, item_position);
+             break;
+         case MAT_C_DOUBLE: /* 6 */
+         case MAT_C_SINGLE: /* 7 */
+             CreateDoubleVariable(pvApiCtx, iVar, matVariable, parent, item_position);
+             break;
+         case MAT_C_INT8: /* 8 */
 -            CreateIntegerVariable(pvApiCtx, iVar, I_CHAR, matVariable, parent, item_position);
++            CreateIntegerVariable(pvApiCtx, iVar, SCI_INT8, matVariable, parent, item_position);
+             break;
+         case MAT_C_UINT8: /* 9 */
+             if (matVariable->isLogical != 0)
+             {
+                 CreateBooleanVariable(pvApiCtx, iVar, matVariable, parent, item_position);
+             }
+             else
+             {
 -                CreateIntegerVariable(pvApiCtx, iVar, I_UCHAR, matVariable, parent, item_position);
++                CreateIntegerVariable(pvApiCtx, iVar, SCI_UINT8, matVariable, parent, item_position);
+             }
+             break;
+         case MAT_C_INT16: /* 10 */
 -            CreateIntegerVariable(pvApiCtx, iVar, I_INT16, matVariable, parent, item_position);
++            CreateIntegerVariable(pvApiCtx, iVar, SCI_INT16, matVariable, parent, item_position);
+             break;
+         case MAT_C_UINT16: /* 11 */
 -            CreateIntegerVariable(pvApiCtx, iVar, I_UINT16, matVariable, parent, item_position);
++            CreateIntegerVariable(pvApiCtx, iVar, SCI_UINT16, matVariable, parent, item_position);
+             break;
+         case MAT_C_INT32: /* 12 */
 -            CreateIntegerVariable(pvApiCtx, iVar, I_INT32, matVariable, parent, item_position);
++            CreateIntegerVariable(pvApiCtx, iVar, SCI_INT32, matVariable, parent, item_position);
+             break;
+         case MAT_C_UINT32: /* 13 */
 -            CreateIntegerVariable(pvApiCtx, iVar, I_UINT32, matVariable, parent, item_position);
++            CreateIntegerVariable(pvApiCtx, iVar, SCI_UINT32, matVariable, parent, item_position);
+             break;
+         case MAT_C_OBJECT: /* 3 to be written */
+         case MAT_C_INT64: /* 14: no Scilab equivalent */
+         case MAT_C_UINT64: /* 15: no Scilab equivalent */
+         case MAT_C_FUNCTION: /* 16 to be written */
+         default:
+             /* Empty matrix returned */
+             if (parent == NULL)
+             {
+                 createEmptyMatrix(pvApiCtx, iVar);
+             }
+             else
+             {
+                 sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, 0, 0, NULL);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     return 0;
+                 }
+             }
+             return FALSE;
      }
  
-   return TRUE;
+     return TRUE;
  }
@@@ -29,7 -29,7 +29,7 @@@
   *
   * @return TRUE if the variable has been written without problem
   */
- MATIO_IMPEXP int CreateMatlabVariable(void* pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position);
 -int CreateMatlabVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position);
++MATIO_IMPEXP int CreateMatlabVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position);
  
  
  /*
   */
  
  #include "CreateMatlabVariable.h"
 -#include "stack-c.h"
  #include "api_scilab.h"
- #include "scisparse.h"
  #include "MALLOC.h"
  #include "localization.h"
  #include "Scierror.h"
  #include "sciprint.h"
- #define MATIO_ERROR if(_SciErr.iErr) \
-     {                              \
-       printError(&_SciErr, 0);             \
-       return 0;                            \
-     }
++#include "scisparse.h"
  
  /* Defined in SCI/modules/sparse/src/fortran/spt.f */
- extern int C2F(spt)(int *m, int *n, int *nel, int *it, int *workArray, 
-                   double *A_R, double *A_I, int *A_mnel, int *A_icol,
-                   double *At_R, double *At_I, int *At_mnel, int *At_icol);
-                  
- int CreateSparseVariable(void* pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
+ extern int C2F(spt)(int *m, int *n, int *nel, int *it, int *workArray,
+                     double *A_R, double *A_I, int *A_mnel, int *A_icol,
+                     double *At_R, double *At_I, int *At_mnel, int *At_icol);
+ int CreateSparseVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
  {
-   int K = 0;
-   sparse_t *sparseData = NULL;
-   SciSparse *scilabSparse = NULL;
-   SciSparse *scilabSparseT = NULL; /* Transpose */
-   int *colIndexes = NULL;
-   int *rowIndexes = NULL;
-   int *workArray = NULL;
-   struct ComplexSplit *complexData = NULL;
-   SciErr _SciErr;
+     int K = 0;
+     mat_sparse_t *sparseData = NULL;
+     SciSparse *scilabSparse = NULL;
+     SciSparse *scilabSparseT = NULL; /* Transpose */
+     int *colIndexes = NULL;
+     int *rowIndexes = NULL;
+     int *workArray = NULL;
+     struct mat_complex_split_t *complexData = NULL;
+     SciErr sciErr;
  
-   sparseData = (sparse_t*) matVariable->data;
+     sparseData = (mat_sparse_t*) matVariable->data;
  
-   scilabSparse = (SciSparse*) MALLOC(sizeof(SciSparse));
-   if (scilabSparse==NULL)
+     scilabSparse = (SciSparse*) MALLOC(sizeof(SciSparse));
+     if (scilabSparse == NULL)
      {
-       Scierror(999, _("%s: No more memory.\n"), "CreateSparseVariable");
-       return FALSE;
+         Scierror(999, _("%s: No more memory.\n"), "CreateSparseVariable");
+         return FALSE;
      }
  
-   /* Computes column indexes from Matlab indexes */
-   if (sparseData->njc > 1)
+     /* Computes column indexes from Matlab indexes */
+     if (sparseData->njc > 1)
      {
-       colIndexes = (int*) MALLOC(sizeof(int) *  (sparseData->njc-1));
-       if (colIndexes==NULL)
+         colIndexes = (int*) MALLOC(sizeof(int) *  (sparseData->njc - 1));
+         if (colIndexes == NULL)
          {
-           Scierror(999, _("%s: No more memory.\n"), "CreateSparseVariable");
-           return FALSE;
+             Scierror(999, _("%s: No more memory.\n"), "CreateSparseVariable");
+             return FALSE;
          }
-       
-       for (K=0; K<sparseData->njc-1; K++)
+         for (K = 0; K < sparseData->njc - 1; K++)
          {
-           colIndexes[K] = sparseData->jc[K+1] - sparseData->jc[K];
+             colIndexes[K] = sparseData->jc[K + 1] - sparseData->jc[K];
          }
      }
  
   *
   */
  
- #include "CreateMatlabVariable.h"
 -#ifdef _MSC_VER
 -#include "strdup_Windows.h"
 -#endif
 -
 +#include "os_strdup.h"
+ #include "CreateMatlabVariable.h"
  #include "freeArrayOfString.h"
  #include "api_scilab.h"
  #include "MALLOC.h"
@@@ -38,7 -35,10 +32,9 @@@ int CreateStructVariable(void *pvApiCtx
      matvar_t ** allData = NULL;
      int * cell_addr = NULL;
      int * cell_entry_addr = NULL;
-     SciErr _SciErr;
 -    int type;
+     SciErr sciErr;
+     int *piDims = NULL;
+     int i = 0;
  
      /* Fields of the struct */
      nbFields = 2; /* "st" "dims" */
@@@ -66,8 -66,8 +62,8 @@@
  
      for (fieldIndex = 1; fieldIndex < nbFields - 1; fieldIndex++)
      {
-         fieldMatVar = Mat_VarGetStructField(matVariable, &fieldIndex, BY_INDEX, 0);
+         fieldMatVar = Mat_VarGetStructField(matVariable, &fieldIndex, MAT_BY_INDEX, 0);
 -        fieldNames[fieldIndex + 1] = strdup(fieldMatVar->name);
 +        fieldNames[fieldIndex + 1] = os_strdup(fieldMatVar->name);
          if (fieldNames[fieldIndex + 1] == NULL)
          {
              Scierror(999, _("%s: No more memory.\n"), "CreateStructVariable");
      }
      else /* 3 or more dimensions -> Scilab HyperMatrix */
      {
-         /*      type = I_INT32;
-               CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,
-                                       &type, &matVariable->rank, matVariable->dims, matVariable->data,
-                                       NULL, cell_addr, 2);
-         */
 -        type = I_INT32;
 -        CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,
 -                                  &type, &matVariable->rank, piDims, (double*)matVariable->data,
 -                                  NULL, cell_addr, 2);
++        //type = I_INT32;
++        //CreateHyperMatrixVariable(pvApiCtx, iVar, MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE,
++        //                          &type, &matVariable->rank, piDims, (double*)matVariable->data,
++        //                          NULL, cell_addr, 2);
      }
  
+     FREE(piDims);
      /* ALL OTHER ENTRIES: Fields data */
      prodDims = 1;
      for (K = 0; K < matVariable->rank; K++)
@@@ -14,7 -14,7 +14,6 @@@
  #include "GetMatlabVariable.h"
  #include "sci_types.h"
  #include "api_scilab.h"
--
  #include "freeArrayOfString.h"
  #include "MALLOC.h"
  
  #include "api_scilab.h"
  #include "sci_types.h"
  #include "freeArrayOfString.h"
- #include "os_strdup.h"
 -#ifdef _MSC_VER
 -#include "strdup_windows.h"
 -#endif
+ #include "MALLOC.h"
  #include "localization.h"
  
- #define MATIO_ERROR if(_SciErr.iErr)            \
-     {                                           \
-         printError(&_SciErr, 0);                \
-         return 0;                               \
-     }
- matvar_t *GetCharVariable(void* pvApiCtx, int iVar, const char *name, int * parent, int item_position)
+ matvar_t *GetCharVariable(void *pvApiCtx, int iVar, const char *name, int * parent, int item_position)
  {
-     char * dataAdr = NULL;
      int rank = 0, i = 0, j = 0;
-     int *dims = NULL;
+     size_t *pszDims = NULL;
+     int *piDims = NULL;
      matvar_t *createdVar = NULL;
      int* piLen = NULL;
-     char ** tmp_char = NULL;
      char** pstData = NULL;
      char* pstMatData = NULL;
      int * piAddr = NULL;
@@@ -33,7 -34,7 +34,7 @@@
   *
   * @return Matlab variable (See MATIO library)
   */
- MATIO_IMPEXP matvar_t *GetMatlabVariable(void* pvApiCtx, int iVar, const char *name, int matfile_version, int * parent, int item_position);
 -matvar_t *GetMatlabVariable(void *pvApiCtx, int iVar, const char *name, int matfile_version, int * parent, int item_position);
++MATIO_IMPEXP matvar_t *GetMatlabVariable(void *pvApiCtx, int iVar, const char *name, int matfile_version, int * parent, int item_position);
  
  /*
   * Get a Matlab Integer variable from stack
@@@ -16,7 -16,7 +16,6 @@@
  #include "GetMatlabVariable.h"
  #include "sci_types.h"
  #include "api_scilab.h"
--
  #include "freeArrayOfString.h"
  #include "MALLOC.h"
  
   */
  
  #include "GetMatlabVariable.h"
 -#include "stack-c.h"
  #include "api_scilab.h"
 +#include "scisparse.h"
  
- #define MATIO_ERROR if(_SciErr.iErr) \
-     {                              \
-       printError(&_SciErr, 0);             \
-       return 0;                            \
-     }
- matvar_t *GetSparseVariable(void* pvApiCtx, int iVar, const char *name, int * parent, int item_position)
+ matvar_t *GetSparseVariable(void *pvApiCtx, int iVar, const char *name, int * parent, int item_position)
  {
      int K = 0;
      int rank = 0;