From 0345245e860375a32c9a437c4a9d9cae807134e9 Mon Sep 17 00:00:00 2001
From: Shashank
Date: Mon, 29 May 2017 12:40:26 +0530
Subject: CMSCOPE changed

---
 modules/string/macros/%_strsplit.bin            | Bin 0 -> 15208 bytes
 modules/string/macros/%_strsplit.sci            | 137 ++++
 modules/string/macros/%ip_part.bin              | Bin 0 -> 4044 bytes
 modules/string/macros/%ip_part.sci              |  40 ++
 modules/string/macros/%mc_string.bin            | Bin 0 -> 4024 bytes
 modules/string/macros/%mc_string.sci            |  46 ++
 modules/string/macros/%p_part.bin               | Bin 0 -> 3360 bytes
 modules/string/macros/%p_part.sci               |  29 +
 modules/string/macros/%plist_string.bin         | Bin 0 -> 4672 bytes
 modules/string/macros/%plist_string.sci         |  46 ++
 modules/string/macros/arobasestring2strings.bin | Bin 0 -> 5288 bytes
 modules/string/macros/arobasestring2strings.sci |  61 ++
 modules/string/macros/ascii2string.bin          | Bin 0 -> 1092 bytes
 modules/string/macros/ascii2string.sci          |  18 +
 modules/string/macros/asciimat.bin              | Bin 0 -> 8804 bytes
 modules/string/macros/asciimat.sci              |  60 ++
 modules/string/macros/blanks.bin                | Bin 0 -> 2732 bytes
 modules/string/macros/blanks.sci                |  32 +
 modules/string/macros/buildmacros.bat           |   1 +
 modules/string/macros/buildmacros.sce           |   9 +
 modules/string/macros/cat_code.bin              | Bin 0 -> 1968 bytes
 modules/string/macros/cat_code.sci              |  28 +
 modules/string/macros/cleanmacros.bat           |   3 +
 modules/string/macros/eval.bin                  | Bin 0 -> 2460 bytes
 modules/string/macros/eval.sci                  |  32 +
 modules/string/macros/evstr.bin                 | Bin 0 -> 6852 bytes
 modules/string/macros/evstr.sci                 |  81 +++
 modules/string/macros/expression2code.bin       | Bin 0 -> 46740 bytes
 modules/string/macros/expression2code.sci       | 360 +++++++++++
 modules/string/macros/format_txt.bin            | Bin 0 -> 3808 bytes
 modules/string/macros/format_txt.sci            |  39 ++
 modules/string/macros/instruction2code.bin      | Bin 0 -> 53812 bytes
 modules/string/macros/instruction2code.sci      | 319 +++++++++
 modules/string/macros/justify.bin               | Bin 0 -> 9552 bytes
 modules/string/macros/justify.sci               |  73 +++
 modules/string/macros/lib                       | Bin 0 -> 764 bytes
 modules/string/macros/names                     |  21 +
 modules/string/macros/rhs2code.bin              | Bin 0 -> 3672 bytes
 modules/string/macros/rhs2code.sci              |  50 ++
 modules/string/macros/sci2exp.bin               | Bin 0 -> 127420 bytes
 modules/string/macros/sci2exp.sci               | 818 ++++++++++++++++++++++++
 modules/string/macros/strcmpi.bin               | Bin 0 -> 312 bytes
 modules/string/macros/strcmpi.sci               |  17 +
 modules/string/macros/tokenpos.bin              | Bin 0 -> 3632 bytes
 modules/string/macros/tokenpos.sci              |  29 +
 modules/string/macros/tree2code.bin             | Bin 0 -> 7996 bytes
 modules/string/macros/tree2code.sci             |  71 ++
 47 files changed, 2420 insertions(+)
 create mode 100755 modules/string/macros/%_strsplit.bin
 create mode 100755 modules/string/macros/%_strsplit.sci
 create mode 100755 modules/string/macros/%ip_part.bin
 create mode 100755 modules/string/macros/%ip_part.sci
 create mode 100755 modules/string/macros/%mc_string.bin
 create mode 100755 modules/string/macros/%mc_string.sci
 create mode 100755 modules/string/macros/%p_part.bin
 create mode 100755 modules/string/macros/%p_part.sci
 create mode 100755 modules/string/macros/%plist_string.bin
 create mode 100755 modules/string/macros/%plist_string.sci
 create mode 100755 modules/string/macros/arobasestring2strings.bin
 create mode 100755 modules/string/macros/arobasestring2strings.sci
 create mode 100755 modules/string/macros/ascii2string.bin
 create mode 100755 modules/string/macros/ascii2string.sci
 create mode 100755 modules/string/macros/asciimat.bin
 create mode 100755 modules/string/macros/asciimat.sci
 create mode 100755 modules/string/macros/blanks.bin
 create mode 100755 modules/string/macros/blanks.sci
 create mode 100755 modules/string/macros/buildmacros.bat
 create mode 100755 modules/string/macros/buildmacros.sce
 create mode 100755 modules/string/macros/cat_code.bin
 create mode 100755 modules/string/macros/cat_code.sci
 create mode 100755 modules/string/macros/cleanmacros.bat
 create mode 100755 modules/string/macros/eval.bin
 create mode 100755 modules/string/macros/eval.sci
 create mode 100755 modules/string/macros/evstr.bin
 create mode 100755 modules/string/macros/evstr.sci
 create mode 100755 modules/string/macros/expression2code.bin
 create mode 100755 modules/string/macros/expression2code.sci
 create mode 100755 modules/string/macros/format_txt.bin
 create mode 100755 modules/string/macros/format_txt.sci
 create mode 100755 modules/string/macros/instruction2code.bin
 create mode 100755 modules/string/macros/instruction2code.sci
 create mode 100755 modules/string/macros/justify.bin
 create mode 100755 modules/string/macros/justify.sci
 create mode 100755 modules/string/macros/lib
 create mode 100755 modules/string/macros/names
 create mode 100755 modules/string/macros/rhs2code.bin
 create mode 100755 modules/string/macros/rhs2code.sci
 create mode 100755 modules/string/macros/sci2exp.bin
 create mode 100755 modules/string/macros/sci2exp.sci
 create mode 100755 modules/string/macros/strcmpi.bin
 create mode 100755 modules/string/macros/strcmpi.sci
 create mode 100755 modules/string/macros/tokenpos.bin
 create mode 100755 modules/string/macros/tokenpos.sci
 create mode 100755 modules/string/macros/tree2code.bin
 create mode 100755 modules/string/macros/tree2code.sci

(limited to 'modules/string/macros')

diff --git a/modules/string/macros/%_strsplit.bin b/modules/string/macros/%_strsplit.bin
new file mode 100755
index 000000000..cf8e08694
Binary files /dev/null and b/modules/string/macros/%_strsplit.bin differ
diff --git a/modules/string/macros/%_strsplit.sci b/modules/string/macros/%_strsplit.sci
new file mode 100755
index 000000000..b8d5f86a2
--- /dev/null
+++ b/modules/string/macros/%_strsplit.sci
@@ -0,0 +1,137 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2009-2010 - Allan CORNET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [strs, matched_separators] = %_strsplit(varargin)
+
+    //====== private macros ==================
+    function out_str = replace_regexp_char(in_str)
+        out_str = strsubst(in_str, "\", "\\");
+        out_str = strsubst(out_str, "/", "\/");
+        out_str = strsubst(out_str, "|", "\|");
+        out_str = strsubst(out_str, ".", "\.");
+        out_str = strsubst(out_str, "$", "\$");
+        out_str = strsubst(out_str, "[", "\[");
+        out_str = strsubst(out_str, "]", "\]");
+        out_str = strsubst(out_str, "(", "\(");
+        out_str = strsubst(out_str, ")", "\)");
+        out_str = strsubst(out_str, "{", "\{");
+        out_str = strsubst(out_str, "}", "\}");
+        out_str = strsubst(out_str, "^", "\^");
+        out_str = strsubst(out_str, "?", "\?");
+        out_str = strsubst(out_str, "*", "\*");
+        out_str = strsubst(out_str, "+", "\+");
+        out_str = strsubst(out_str, "-", "\-");
+    endfunction
+    //========================================
+    function bOK = isPattern(str)
+        bOK = %f;
+        lenstr = length(str);
+        if lenstr > 1 then
+            bOK = ((part(str, 1) == "/") & (part(str, lenstr) == "/"));
+        end
+    endfunction
+    //========================================
+    function regexp_pattern = createPattern(StringsInput)
+        dims_StringsInput = size(StringsInput,"*");
+        if (dims_StringsInput == 1) then
+            if ~isPattern(StringsInput) then
+                regexp_pattern = "/" + replace_regexp_char(StringsInput) + "/";
+            else
+                regexp_pattern = StringsInput;
+            end
+        else
+            regexp_pattern = "";
+            for i = 1:dims_StringsInput
+                if (i == 1) then
+                    regexp_pattern = replace_regexp_char(StringsInput(i));
+                else
+                    regexp_pattern = regexp_pattern + "|" + replace_regexp_char(StringsInput(i));
+                end
+            end
+            regexp_pattern = "/" + regexp_pattern + "/";
+        end
+    endfunction
+    //========================================
+    matched_separators = [];
+    strs = [];
+
+    [lhs, rhs] = argn(0);
+
+    // input types are checked in strsplit primitive
+    if (rhs == 1) then
+        len = length(varargin(1));
+        if len == 0 then
+            strs = "";
+        else
+            len = length(varargin(1));
+            if len > 1 then
+                strs = strsplit( varargin(1), 1:len - 1 );
+            else
+                strs = varargin(1);
+            end
+        end
+        if (lhs == 2) then
+            dims_strs = size(strs);
+            matched_separators = emptystr(dims_strs(1), dims_strs(2));
+        end
+    else
+
+        strsplit_limit = -1; // no limit
+        if (rhs == 3) then
+            strsplit_limit = varargin(3);
+        end
+
+        if varargin(2) == "" then
+            [strs, matched_separators] = strsplit(varargin(1));
+        else
+            strsplit_pattern = createPattern(varargin(2));
+
+            [start_regexp, end_regexp, match_regexp] =  regexp(varargin(1), strsplit_pattern);
+            if (start_regexp <> []) then
+                if (end_regexp($) == length(varargin(1))) then
+                    end_regexp($) = end_regexp($) - 1;
+                end
+
+                len = length(varargin(1));
+                if len > 1 then
+                    strs = strsplit(varargin(1), end_regexp);
+                    strs = strsubst(strs, strsplit_pattern, "", "r");
+                    matched_separators = match_regexp;
+                else
+                    strs = varargin(1);
+                    matched_separators = [];
+                end
+            else
+                strs = varargin(1);
+                matched_separators = [];
+            end
+        end
+
+        if (strsplit_limit > 0) then
+            dim_strs = size(strs,"*");
+            if (strsplit_limit >= dim_strs) then
+                strsplit_limit = dim_strs;
+            else
+                strsremain = strs(strsplit_limit + 1 : $);
+                dim_strsremain = size(strsremain,"*");
+                strslimited = strs(1:strsplit_limit);
+
+                foundedremain = matched_separators(strsplit_limit + 1 : $);
+                foundedremain($ + 1: dim_strsremain) = "";
+                matched_separators = matched_separators(1:strsplit_limit);
+
+                str = strsremain + foundedremain;
+                strs = [strslimited ; strcat(str)];
+            end
+        end
+    end
+    //========================================
+
+endfunction
+
diff --git a/modules/string/macros/%ip_part.bin b/modules/string/macros/%ip_part.bin
new file mode 100755
index 000000000..c0efa34f5
Binary files /dev/null and b/modules/string/macros/%ip_part.bin differ
diff --git a/modules/string/macros/%ip_part.sci b/modules/string/macros/%ip_part.sci
new file mode 100755
index 000000000..f8c2d97af
--- /dev/null
+++ b/modules/string/macros/%ip_part.sci
@@ -0,0 +1,40 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) - 2013 - Samuel GOUGEON
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function r = %ip_part(txt, s)
+    // Allows calls such as: part(txt, $:-1:1)  // (== strrev() )
+    // Calls with unranging $ are not supported => define %p_part()
+    // txt may be a matrix of texts with different lengths
+    //  => $ might not have the same value for all of them
+    function b = checkip(p)
+        b = checkvar(p(1)) & checkvar(p(2)) & checkvar(p(3));
+    endfunction
+
+    function b = checkvar(p)
+        b = %t;
+        if typeof(p) == "polynomial" & varn(p) ~= "$" then
+            b = %f;
+        end
+    endfunction
+
+    //check s
+    if ~checkip(s) then
+        msg = _("%s: Wrong value for input argument #%d: $ expected.\n");
+        error(msprintf(msg,"part",2))
+    end
+
+    L = length(txt)
+    U = unique(L)
+    r = emptystr(txt)
+    for u = U(:)'
+        j = 1:u
+        k = find(L==u)
+        r(k) = part(txt(k), j(s))
+    end
+endfunction
diff --git a/modules/string/macros/%mc_string.bin b/modules/string/macros/%mc_string.bin
new file mode 100755
index 000000000..a7e403a51
Binary files /dev/null and b/modules/string/macros/%mc_string.bin differ
diff --git a/modules/string/macros/%mc_string.sci b/modules/string/macros/%mc_string.sci
new file mode 100755
index 000000000..a1896eaab
--- /dev/null
+++ b/modules/string/macros/%mc_string.sci
@@ -0,0 +1,46 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2011 - Allan CORNET
+// Copyright (C) INRIA - 2011 - Serge STEER
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [vars_out, vars_in, fun_text] = %mc_string(pfunc)
+
+    vars_out = [];
+    vars_in = [];
+    fun_text = [];
+
+    if type(pfunc) <> 13 then
+        error(999, msprintf(gettext("%s: Wrong type for input argument #%d: a function expected.\n"), "string", 1));
+    end
+
+    //fun2string referenced to make its subfunctions known there
+    prot = funcprot();
+    funcprot(0);
+    fun2string = fun2string;
+    funcprot(prot);
+    //get the function pseudo code
+    lst = mmodlst(macr2lst(pfunc));
+
+    //get the input and output variable names
+    vars_in = lst(3);
+    vars_out = lst(2);
+
+    //re-generate the source code from pseudo-code (see fun2string)
+    lcount = 1;
+    level = [0, 0];
+    quote = "''";
+    dquote = """";
+    CR = "\" + ascii(10);
+    opstable();
+    sciexp = 0;
+    crp = ins2sci(lst, 4);
+    fun_text = crp(1:$-2);
+    if fun_text(1) == "" then fun_text(1) = " ", end
+    if fun_text($) == "" then fun_text($) = " ", end
+
+endfunction
diff --git a/modules/string/macros/%p_part.bin b/modules/string/macros/%p_part.bin
new file mode 100755
index 000000000..911838d7f
Binary files /dev/null and b/modules/string/macros/%p_part.bin differ
diff --git a/modules/string/macros/%p_part.sci b/modules/string/macros/%p_part.sci
new file mode 100755
index 000000000..1930c3e5f
--- /dev/null
+++ b/modules/string/macros/%p_part.sci
@@ -0,0 +1,29 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) - 2013 - Samuel GOUGEON
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function r = %p_part(txt, s)
+    // Allows calls such as: part(txt, [ 2 $ 3:4 $-1])
+    //  with un-ranging implicit size $ standing for length(txt)
+    // Calls with ranging $ (ex: 3:$ ) are implemented with %ip_part()
+    //
+    // txt may be a matrix of texts with different lengths
+    //  => $ might have not the same value for all elements of txt.
+    if varn(s)~="$" then
+        msg = _("%s: $ is the only implicit variable supported in selected indices")
+        error(msprintf(msg,"part"))
+    end
+    L = length(txt)
+    U = unique(L)
+    r = emptystr(txt)
+    for u = U(:)'
+        j = 1:u
+        k = find(L==u)
+        r(k) = part(txt(k), horner(s(:)',u))
+    end
+endfunction
diff --git a/modules/string/macros/%plist_string.bin b/modules/string/macros/%plist_string.bin
new file mode 100755
index 000000000..906221720
Binary files /dev/null and b/modules/string/macros/%plist_string.bin differ
diff --git a/modules/string/macros/%plist_string.sci b/modules/string/macros/%plist_string.sci
new file mode 100755
index 000000000..fa1f7d815
--- /dev/null
+++ b/modules/string/macros/%plist_string.sci
@@ -0,0 +1,46 @@
+// Copyright (C) 2010 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+//
+// %plist_string --
+//   Returns the string containing the parameters list.
+//
+function str = %plist_string ( this )
+
+    // In case there is a function field
+    prot = funcprot()
+    funcprot(0)
+
+    fieldmat = getfield(1, this);
+    nf = size(fieldmat, "*") - 1;
+    str = emptystr(nf+3, 1); // Allocating the result
+    str(1) = sprintf("Parameters list:"); // Headers
+    str(2) = sprintf("================");
+    str(3) = sprintf("Number of fields = %d", nf);
+
+    k = 3; // Start printing after headers
+    for i = 1 : nf
+        key = fieldmat(i+1);
+        value = getfield(i+1, this);
+        if ( or ( typeof(value) == ["constant" "boolean" "string" ] ) ) then
+            k = k + 1;
+            if ( size(value, "*") == 1 ) then
+                str(k) = sprintf("%s = %s (""%s"")", key , string(value) , typeof(value) );
+            else
+                siz = size(value);
+                str(k) = sprintf("%s = ""%s"" %dx%d ", key , typeof(value) , siz(1), siz(2) );
+            end
+        else
+            k = k + 1;
+            str(k) = sprintf("%s = ""%s""", key , typeof(value) );
+        end
+    end
+
+    funcprot(prot)
+
+endfunction
diff --git a/modules/string/macros/arobasestring2strings.bin b/modules/string/macros/arobasestring2strings.bin
new file mode 100755
index 000000000..ae77b6ffa
Binary files /dev/null and b/modules/string/macros/arobasestring2strings.bin differ
diff --git a/modules/string/macros/arobasestring2strings.sci b/modules/string/macros/arobasestring2strings.sci
new file mode 100755
index 000000000..62794e9b4
--- /dev/null
+++ b/modules/string/macros/arobasestring2strings.sci
@@ -0,0 +1,61 @@
+//==========================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Jean-baptiste SILVY
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Desc   : Convert the string format defined by jpc into matrix of strings
+//==========================================================================
+
+
+function [strings] = arobasestring2strings( varargin )
+
+    // call : arobasestring2strings( string )
+
+    [lhs,rhs] = argn(0) ;
+
+    // check number of arguments
+    if ( rhs ~= 1 ) then
+        error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"arobasestring2strings",1));
+        return ;
+    end
+
+    cText = varargin(1) ;
+
+    // check type
+    if ( type(cText) ~= 10 ) then
+        error(msprintf(gettext("%s: Wrong type for input argument: String expected.\n"),"arobasestring2strings"));
+        return ;
+    end
+
+    // check the size
+    if ( size( cText ) <> 1 ) then
+        error(msprintf(gettext("%s: Wrong size for input argument #%d: A character string expected.\n"),"arobasestring2strings",1));
+        return ;
+    end
+
+    // in the text, each line is separated by a '@' character
+    // in the resulting matrix, each line is put on a line
+    // of the matrix
+
+    // positions of @ in
+    arobPos = strindex( cText, "@" ) ;
+
+    nbArob = size( arobPos ) ;
+    nbArob = nbArob(2);
+
+    // add the last character
+    arobPos( nbArob + 1 ) = length( cText ) + 1 ;
+
+    // get the first string
+    strings(1) = part( cText, [1:arobPos(1)-1] ) ;
+
+    for i = 1 : nbArob
+        strings( i + 1 ) = part( cText, [ arobPos(i) + 1 : arobPos(i+1) - 1 ] ) ;
+    end
+
+endfunction
diff --git a/modules/string/macros/ascii2string.bin b/modules/string/macros/ascii2string.bin
new file mode 100755
index 000000000..435fe9ef5
Binary files /dev/null and b/modules/string/macros/ascii2string.bin differ
diff --git a/modules/string/macros/ascii2string.sci b/modules/string/macros/ascii2string.sci
new file mode 100755
index 000000000..328276199
--- /dev/null
+++ b/modules/string/macros/ascii2string.sci
@@ -0,0 +1,18 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function ww=ascii2string(w1)
+    //converts a numeric (real or integer) matrix made of ascii codes
+    //into a one column scilab string matrix and conversely.
+    ww=[];
+    for k=1:size(w1,1)
+        ww=[ww;ascii(w1(k,:))];
+    end
+endfunction
diff --git a/modules/string/macros/asciimat.bin b/modules/string/macros/asciimat.bin
new file mode 100755
index 000000000..e8fbb3393
Binary files /dev/null and b/modules/string/macros/asciimat.bin differ
diff --git a/modules/string/macros/asciimat.sci b/modules/string/macros/asciimat.sci
new file mode 100755
index 000000000..ebfc0a771
--- /dev/null
+++ b/modules/string/macros/asciimat.sci
@@ -0,0 +1,60 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ???? - INRIA - Scilab
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y=asciimat(x)
+    // This function converts a matrix of string into a matrix of ascii codes using ascii() Scilab function
+    // and converts an array of ascii codes into a array of string
+    // Returned value have same size as input value instead of second dims !
+    // Fonction created because ascii() Scilab function returns a row vector
+    if size(size(x),"*")<=2 then
+        if type(x)==10 then
+            if x==[] then
+                y=[]
+                return
+            else
+                ytemp=[];
+                for i=1:size(x,1)
+                    ytemp=[ytemp ascii(x(i,:))]
+                end
+                nbcol= size(ytemp,"*")*size(x,2)/size(x,"*")
+                if nbcol-floor(nbcol)<>0 then
+                    error(msprintf(gettext("%s: Wrong input argument #%d: Inconsistent size.\n"),"asciimat", 1));
+                end
+                y=[]
+                for i=1:size(x,1)
+                    y=[y ;ytemp(1+(i-1)*nbcol:i*nbcol)]
+                end
+            end
+        elseif type(x)==1 | type(x)==8 then
+            y=[]
+            for k=1:size(x,1)
+                y(k)=ascii(x(k,:))
+            end
+        else
+            error(msprintf(gettext("%s: Wrong type for input argument #%d: A Real, Integer or String matrix expected.\n"),"asciimat", 1));
+        end
+    elseif size(size(x),"*")>2 then
+        if typeof(x)=="hypermat" then
+            if type(x.entries)==1 | type(x.entries)==8
+                n=size(size(x),"*")
+                dims=size(x)
+                dims=[dims(1),dims(3:n)]
+                V=" "
+                D=prod(dims)
+                DD=D/size(x,1)
+                V=part(V,ones(1,size(x,2)))
+                V=V+emptystr(D,1)
+                for l=1:DD
+                    V((l-1)*size(x,1)+1:l*size(x,1))=asciimat(x(:,:,l))
+                end
+                y=hypermat(dims,V)
+            end
+        end
+    end
+endfunction
diff --git a/modules/string/macros/blanks.bin b/modules/string/macros/blanks.bin
new file mode 100755
index 000000000..0abbd2487
Binary files /dev/null and b/modules/string/macros/blanks.bin differ
diff --git a/modules/string/macros/blanks.sci b/modules/string/macros/blanks.sci
new file mode 100755
index 000000000..80c93ddce
--- /dev/null
+++ b/modules/string/macros/blanks.sci
@@ -0,0 +1,32 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Allan CORNET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// blanks macro
+// blanks(n)
+// Create string of blank characters
+
+function str = blanks(n)
+
+    if ~or(type(n)==[1,8]) then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer expected.\n"),"blanks",1));
+    end
+
+    if and(size(n)<>[1 1]) then
+        error(msprintf(gettext("%s: Wrong size for input argument #%d: An integer expected.\n"),"blanks",1));
+    end
+
+    if n>0 then
+        str = part(" ",ones(1,n));
+    elseif n==0
+        str = "";
+    else
+        error(msprintf(gettext("%s: Wrong values for input argument #%d: An non-negative integer expected.\n"),"blanks",1));
+    end
+
+endfunction
diff --git a/modules/string/macros/buildmacros.bat b/modules/string/macros/buildmacros.bat
new file mode 100755
index 000000000..c4e35ec40
--- /dev/null
+++ b/modules/string/macros/buildmacros.bat
@@ -0,0 +1 @@
+@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit;
\ No newline at end of file
diff --git a/modules/string/macros/buildmacros.sce b/modules/string/macros/buildmacros.sce
new file mode 100755
index 000000000..1383b10df
--- /dev/null
+++ b/modules/string/macros/buildmacros.sce
@@ -0,0 +1,9 @@
+//------------------------------------
+// Allan CORNET INRIA 2005
+//------------------------------------
+if (isdef("genlib") == %f) then
+    exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce");
+end
+//------------------------------------
+genlib("stringlib","SCI/modules/string/macros",%f,%t);
+//------------------------------------
diff --git a/modules/string/macros/cat_code.bin b/modules/string/macros/cat_code.bin
new file mode 100755
index 000000000..4ebb176ce
Binary files /dev/null and b/modules/string/macros/cat_code.bin differ
diff --git a/modules/string/macros/cat_code.sci b/modules/string/macros/cat_code.sci
new file mode 100755
index 000000000..9152f2df7
--- /dev/null
+++ b/modules/string/macros/cat_code.sci
@@ -0,0 +1,28 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Vincent COUVERT
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function t=cat_code(a,b)
+
+    // Catenate two parts of code (called by tree2code)
+    // Input:
+    // - a: original code
+    // - b: code to add to a
+    // Output:
+    // - t: catenation of a and b
+
+    if a==[] then
+        t=b
+    elseif b==[] then
+        t=a
+    elseif stripblanks(b)=="" then // b=="" then add a new line
+        t=[a;""];
+    else
+        t=[a(1:$-1);a($)+b(1);b(2:$)]
+    end
+endfunction
diff --git a/modules/string/macros/cleanmacros.bat b/modules/string/macros/cleanmacros.bat
new file mode 100755
index 000000000..5079dfd71
--- /dev/null
+++ b/modules/string/macros/cleanmacros.bat
@@ -0,0 +1,3 @@
+@del *.bin 2>NUL
+@del lib 2>NUL
+@del names 2>NUL
\ No newline at end of file
diff --git a/modules/string/macros/eval.bin b/modules/string/macros/eval.bin
new file mode 100755
index 000000000..fa6411e93
Binary files /dev/null and b/modules/string/macros/eval.bin differ
diff --git a/modules/string/macros/eval.sci b/modules/string/macros/eval.sci
new file mode 100755
index 000000000..65f81483f
--- /dev/null
+++ b/modules/string/macros/eval.sci
@@ -0,0 +1,32 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA -
+// Copyright (C) DIGITEO - 2010 - Allan CORENT
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function _h = eval(z)
+    // Syntax :  H = eval(Z)
+    // returns the evaluation of the matrix of character strings Z.
+    // Example: a=1; b=2; Z=['a','b'] ; eval(Z) returns the matrix [1,2];
+    //!
+
+    _h = [];
+    [mz, nz] = size(z);
+    if mz * nz > 1 then
+        str = [];
+        for l = 1:mz, for k = 1:nz,
+                str = [str; "%_h(" + string(l) + ", " + string(k) + ")=" + z(l,k)];
+            end
+        end
+    else
+        str = "%_h = " + z;
+    end
+    %_h = [];
+    deff("[%_h] = %eval();", str);
+    _h = %eval();
+endfunction
diff --git a/modules/string/macros/evstr.bin b/modules/string/macros/evstr.bin
new file mode 100755
index 000000000..f3b1ff9a3
Binary files /dev/null and b/modules/string/macros/evstr.bin differ
diff --git a/modules/string/macros/evstr.sci b/modules/string/macros/evstr.sci
new file mode 100755
index 000000000..fd407046a
--- /dev/null
+++ b/modules/string/macros/evstr.sci
@@ -0,0 +1,81 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+// Copyright (C) DIGITEO - 2010 - Allan CORNET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function [%val, %ierr] = evstr(%str)
+
+    [lhs, rhs] = argn(0);
+    %val = [];
+    select type(%str)
+
+    case 10 then
+        // matrix of character strings
+
+        // bug 7003
+        if ~isdef("Nan") then
+            Nan = %nan;
+        end
+        if ~isdef("NaN") then
+            NaN = %nan;
+        end
+
+        if ~isdef("Inf") then
+            Inf = %inf;
+        end
+
+        if ~isdef("INF") then
+            INF = %inf;
+        end
+
+        for %l = 1:size(%str, "r")
+            %t1(%l) = strcat(%str(%l, :), ",") + ";"
+        end
+        %t1(1) = "%val=[" + %t1(1);
+        %t1($) = part(%t1($), 1:length(%t1($)) - 1)+";";
+        %t1($+1)="]";
+        if lhs == 2 then
+            %ierr = execstr(%t1, "errcatch");
+        else
+            execstr(%t1)
+        end
+
+    case 15 then
+        // list
+        %sexp = %str(2),
+        %nstr = prod(size(%sexp));
+        % = list();
+        if lhs == 2 then
+            for %k_ = 1:%nstr,
+                [%w, %ierr] = evstr(%sexp(%k_));
+                %(%k_) = %w;
+                if %ierr <>0  then
+                    %val = [];
+                    return;
+                end
+            end
+            [%val, %ierr] = evstr(%str(1));
+        else
+            for %k_ = 1:%nstr,
+                %(%k_) = evstr(%sexp(%k_));
+            end
+            %val = evstr(%str(1))
+        end
+
+    case 1 then
+        // real or complex constant matrix
+        %val = %str;
+        %ierr = 0;
+    else
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: Real or Complex matrix, Matrix of character strings or list expected.\n"), "evstr", 1));
+    end
+    if exists("%val", "local") == 0 then
+        error(msprintf(gettext("%s: Given expression has no value.\n"), "evstr"));
+    end
+endfunction
diff --git a/modules/string/macros/expression2code.bin b/modules/string/macros/expression2code.bin
new file mode 100755
index 000000000..5dad05aa1
Binary files /dev/null and b/modules/string/macros/expression2code.bin differ
diff --git a/modules/string/macros/expression2code.sci b/modules/string/macros/expression2code.sci
new file mode 100755
index 000000000..977a02f40
--- /dev/null
+++ b/modules/string/macros/expression2code.sci
@@ -0,0 +1,360 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Vincent COUVERT
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function C=expression2code(e)
+    // Translate an expression tree to macro code (called by tree2code)
+    // Input:
+    // - e: expression 'tree'
+    // Output:
+    // - C: Scilab code corresponding to e
+    // V.C.
+
+    // Change format for constants
+    fmtsav=format();
+    format(16);
+
+    // Tables of symbols arranged by priority in computations
+    sumops=["+","-","&","|"] //1
+    prodops=["*","/",".*","./","\",".\","^",".^"] //2
+    othops=["==",">=","<=","~=",">","<","~",".''",".''",":"] //3
+
+    C=[]
+    select typeof(e)
+        // ---------
+        // OPERATION
+        // ---------
+    case "operation" then
+        operator=e.operator
+        operands=[]
+        nb_op=size(e.operands)
+        if and(operator<>["cc","cceol"]) then
+            for i=1:nb_op
+                if e.operands(i)==list("EOL") then
+                    continue
+                end
+                expression = expression2code(e.operands(i));
+                if expression == "eye()" then
+                    expression = ":";
+                end
+                operands=[operands;expression]
+            end
+        end
+
+        // Row concatenation
+        if operator=="rc" then
+            for i=1:nb_op
+                if typeof(e.operands(i))=="operation" then
+                    if e.operands(i).operator=="rc" then
+                        operands(i)=part(operands(i),2:length(operands(i))-1)
+                    elseif or(e.operands(i).operator==["cceol"]) then
+                        operands(1)=part(operands(1),2:length(operands(1)))
+                        operands($)=part(operands($),1:length(operands($))-1)
+                    end
+                end
+            end
+            C="["+strcat(operands,",")+"]"
+            // Multi-line column concatenation
+        elseif operator=="cceol" then
+            for i=1:nb_op
+                opi=expression2code(e.operands(i))
+                if typeof(e.operands(i))=="operation" then
+                    if e.operands(i).operator=="rc" then
+                        opi=part(opi,2:length(opi)-1)
+                    elseif or(e.operands(i).operator==["cc","cceol"]) then
+                        opi(1)=part(opi(1),2:length(opi(1)))
+                        opi($)=part(opi($),1:length(opi($))-1)
+                    end
+                end
+
+                if i==1 then
+                    C="["
+                    if size(opi,"*")>1 then
+                        C = [C+opi(1);opi(2:$)]
+                    else
+                        C = C+opi
+                    end
+                    C($)=C($)+";"
+                    C=[C;""]
+                else
+                    if size(opi,"*")>1 then
+                        C = [C(1:$-1);C($)+opi(1);opi(2:$)]
+                    else
+                        C = [C(1:$-1);C($)+opi]
+                    end
+                    C($)=C($)+"]"
+                end
+            end
+            // Column concatenation
+        elseif operator=="cc" then
+            C="["
+            for i=1:nb_op
+                opi=expression2code(e.operands(i))
+                // Delete [ and ] if there are...
+                if typeof(e.operands(i))=="operation" then
+                    if e.operands(i).operator=="rc" then
+                        opi=part(opi,2:length(opi)-1)
+                    elseif or(e.operands(i).operator==["cc","cceol"]) then
+                        opi(1)=part(opi(1),2:length(opi(1)))
+                        opi($)=part(opi($),1:length(opi($))-1)
+                    end
+                end
+                if i==1 then
+                    if size(opi,"*")>1 then
+                        C = [C+opi(1);opi(2:$)]
+                    elseif opi=="(EOL)" then
+                        C = [C;""];
+                    else
+                        C = C+opi
+                    end
+                    C($)=C($)+";"
+                else
+                    if size(opi,"*")>1 then
+                        C = [C(1:$-1);C($)+opi(1);opi(2:$)]
+                    elseif opi=="(EOL)" then
+                        C = [C;""]
+                    else
+                        C = [C(1:$-1);C($)+opi]
+                    end
+                end
+            end
+            C($)=C($)+"]"
+            // Extraction
+        elseif operator=="ext" then
+            if size(e.operands)==1 then
+                C=e.operands(1).name
+                return
+            end
+            if type(e.operands(2))==15 then // Recursive extraction
+                C=operands(1)+operands(2)
+            else
+                // Deal with :
+                for k=2:size(operands,"*")
+                    if operands(k)==""":""" then
+                        operands(k)=":"
+                    elseif operands(k)=="""$""" then
+                        operands(k)="$"
+                    elseif operands(k)=="""*""" then // Only used for M2SCI
+                        operands(k)="*"
+                    end
+                end
+                val = part(operands(2),1)=="""" & part(operands(2),length(operands(2)))==""""
+                if val then // struct field
+                    C=operands(1)+"."+evstr(operands(2))
+                    if size(operands,"*")>=3 then
+                        C=C+"("
+                    end
+                    for k=3:size(operands,"*")
+                        C=C+","+operands(k)
+                    end
+                    if size(operands,"*")>=3 then
+                        C=C+")"
+                    end
+                else
+                    C=operands(1)+"("+operands(2)
+                    for k=3:size(operands,"*")
+                        C=C+","+operands(k)
+                    end
+                    C=C+")"
+                end
+            end
+            // Insertion
+        elseif operator=="ins" then
+            if type(e.operands(2))==15 then // Recursive insertion
+                C=operands(1)+operands(2)
+            else
+                // Deal with :
+                for k=2:size(operands,"*")
+                    if operands(k)==""":""" then
+                        operands(k)=":"
+                    elseif operands(k)=="""$""" then
+                        operands(k)="$"
+                    elseif operands(k)=="""*""" then // Only used in M2SCI
+                        operands(k)="*"
+                    end
+                end
+                val = part(operands(2),1)=="""" & part(operands(2),length(operands(2)))==""""
+                if val then // struct field
+                    C=operands(1)+"."+evstr(operands(2))
+                    if size(operands,"*")>=3 then
+                        C=C+"("
+                    end
+                    for k=3:size(operands,"*")
+                        C=C+","+operands(k)
+                    end
+                    if size(operands,"*")>=3 then
+                        C=C+")"
+                    end
+                else
+                    C=operands(1)+"("+operands(2)
+                    for k=3:size(operands,"*")
+                        C=C+","+operands(k)
+                    end
+                    C=C+")"
+                end
+            end
+            // Unary Operators
+        elseif size(operands,"*")==1 then
+            if or(operator==["''",".''"]) then
+                if typeof(e.operands(1))=="operation" then
+                    if and(e.operands(1).operator<>["rc","cc","-","+"]) then
+                        operands="("+operands+")"
+                    end
+                end
+                C=operands+operator
+            elseif or(operator==["+","-"]) then
+                if typeof(e.operands(1))=="operation" then
+                    if or(e.operands(1).operator==["-","+"]) then
+                        operands="("+operands+")"
+                    end
+                end
+                C=operator+operands
+            else
+                C=operator+operands
+            end
+            // Other operators
+        else
+            // Parenthesize
+            if or(operator==["+","-"]) then
+                for i=1:nb_op
+                    if typeof(e.operands(i))=="operation" then
+                        if or(e.operands(i).operator==othops) then
+                            operands=[operands(1:i-1) "("+operands(i)+")" operands(i+1:$)]
+                        end
+                    end
+                end
+                for i=2:nb_op
+                    if typeof(e.operands(i))=="operation" then
+                        if or(e.operands(i).operator==sumops) then
+                            operands=[operands(1:i-1) "("+operands(i)+")" operands(i+1:$)]
+                        end
+                    end
+                end
+            end
+            if or(operator==[prodops,othops]) & (operator<>":") then
+                if typeof(e.operands(1))=="operation" then
+                    if or(e.operands(1).operator==[sumops,prodops,othops]) then
+                        operands(1)="("+operands(1)+")"
+                    end
+                end
+                if typeof(e.operands(2))=="operation" then
+                    if or(e.operands(2).operator==[sumops,prodops,othops]) then
+                        operands(2)="("+operands(2)+")"
+                    end
+                end
+            end
+            if part(operator,1)=="." & part(operator,length(operator))=="." | or(operator==["&","|"]) then
+                C=strcat(operands," "+operator+" ")
+            elseif part(operator,1)=="." then
+                C=strcat(operands," "+operator)
+            elseif part(operator,length(operator))=="." then
+                C=strcat(operands,operator+" ")
+            else
+                C=strcat(operands,operator)
+            end
+        end
+        // --------
+        // CONSTANT
+        // --------
+    case "cste" then
+        C=sci2exp(e.value)
+        if C==""":""" then
+            //C=":"
+        elseif C=="""$""" then
+            C="$"
+        elseif C=="""*""" then // Only used in M2SCI
+            C="""*"""
+            //  C="*"
+        end
+        // --------
+        // VARIABLE
+        // --------
+    case "variable" then
+        C=e.name
+        // ----------------
+        // CHARACTER STRING
+        // ----------------
+    case "string" then
+        C=e
+        // -------
+        // FUNCALL
+        // -------
+    case "funcall" then
+        if size(e.rhs)==0 then
+            I=I; // I is defined in instruction2code
+            C=e.name
+            [l,mac]=where()
+            if size(grep(mac,"expression2code"),"*")>1 then
+                C=C+"()"
+            elseif typeof(I)=="equal" & ( (typeof(I.lhs(1))=="variable" & I.lhs(1).name<>"ans") | typeof(I.lhs(1))=="operation") then
+                C=C+"()"
+            end
+        else
+            rhscode = rhs2code(e.rhs);
+            if size(rhscode,"*")==1 then
+                C=[e.name+"("+rhscode+")"]
+            else
+                C=[e.name+"("+rhscode(1);rhscode(2:($-1));rhscode($)+")"]
+            end
+        end
+        // ----
+        // LIST
+        // ----
+    case "list"
+        // Recursive extraction
+        C=[]
+        for k=1:lstsize(e)
+            ind=expression2code(e(k))
+            if type(e(k))==15 then // Recursive extraction in recursive extraction
+                ind=strsubst(ind,")(",",")
+                if part(ind, 1)=="(" then
+                    ind = part(ind, 2:length(ind))
+                end
+                if part(ind, length(ind))==")" then
+                    ind = part(ind, 1:(length(ind)-1))
+                end
+            end
+            if ind==""":""" then
+                ind=":"
+            elseif ind=="""$""" then
+                ind="$"
+            elseif ind=="""*""" then // Only used in M2SCI
+                ind="*"
+            end
+            val = part(ind,1)=="""" & part(ind,length(ind))==""""
+            if val then
+                C=C+"."+evstr(ind)
+            else
+                C=C+"("+ind+")"
+            end
+        end
+        C=strsubst(C,")(",",")
+        // -----
+        // EQUAL (can occur fir disp(a=1) for example)
+        // -----
+    case "equal"
+        C=instruction2code(e)
+        // -------
+        // COMMENT (inside a matrix declaration for example)
+        // -------
+    case "comment"
+        C=instruction2code(e)
+    else
+        error(msprintf(gettext("%s: This feature has not been implemented: %s.\n"),"expression2code",typeof(e)));
+    end
+
+    // Restore format
+    if fmtsav(1)==1 then
+        format("v",fmtsav(2));
+    else
+        format("e",fmtsav(2));
+    end
+endfunction
+
+
diff --git a/modules/string/macros/format_txt.bin b/modules/string/macros/format_txt.bin
new file mode 100755
index 000000000..a729d2d08
Binary files /dev/null and b/modules/string/macros/format_txt.bin differ
diff --git a/modules/string/macros/format_txt.sci b/modules/string/macros/format_txt.sci
new file mode 100755
index 000000000..e81d63304
--- /dev/null
+++ b/modules/string/macros/format_txt.sci
@@ -0,0 +1,39 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Vincent COUVERT
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [txt,space]=format_txt(txt,instr,bprettyprintformat,nextinstr)
+    // Add EOL and returns spaces to have good indentation (called by tree2code)
+    // Inputs:
+    // - txt: code to format
+    // - instr: instruction to evaluate as a possible EOL
+    // - bprettyprintformat = %T -> code generated is formated %F -> code generated has same format as original code
+    // - nextinstr: next instruction after instr (format EOL between instructions)
+    // Outputs:
+    // - txt: updated txt
+    // - space: indentation margin for control instructions
+
+    rhs=argn(2)
+
+    // Indentation and EOL in control clauses
+    if rhs==3 then
+        if instr<>list("EOL") & bprettyprintformat then
+            txt = cat_code(txt,"")
+            space="  "
+        elseif instr<>list("EOL") then
+            space=" "
+        else
+            space="  "
+        end
+        // EOL between instructions
+    else
+        if bprettyprintformat & instr<>list("EOL") & nextinstr<>list("EOL") then
+            txt = cat_code(txt,"")
+        end
+    end
+endfunction
diff --git a/modules/string/macros/instruction2code.bin b/modules/string/macros/instruction2code.bin
new file mode 100755
index 000000000..06a9caece
Binary files /dev/null and b/modules/string/macros/instruction2code.bin differ
diff --git a/modules/string/macros/instruction2code.sci b/modules/string/macros/instruction2code.sci
new file mode 100755
index 000000000..3523dfe33
--- /dev/null
+++ b/modules/string/macros/instruction2code.sci
@@ -0,0 +1,319 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - vincent COUVERT
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function  C=instruction2code(I, bprettyprintformat)
+    // Translate an instruction tlist to Scilab code (called by tree2code)
+    // Input:
+    // - I: instruction 'tree'
+    // - bprettyprintformat: boolean value, if FALSE (default value), generated code is not formated else it is
+    // Output:
+    // - C: Scilab code corresponding to I
+
+    // Default value
+    rhs=argn(2)
+    if rhs==1 then
+        bprettyprintformat=%F
+    end
+
+    C=[]
+
+    // -----------
+    // Empty lines
+    // -----------
+    if I==list("EOL") then
+        C=""
+        return
+    end
+
+    // ---------------------------------------------
+    // Generate code corresponding to a TRY-CATCH
+    // ---------------------------------------------
+    if typeof(I)=="trycatch" then
+
+        //TRYCATCH
+        C="try "
+        [C,indent_space] = format_txt(C,I.trystat(1),bprettyprintformat); // Add EOL after while if needed and returns indent_space
+        for k=1:size(I.trystat)
+            C=cat_code(C,indent_space+instruction2code(I.trystat(k)))
+            if k<size(I.trystat) then // Add EOL between statements if needed
+                C = format_txt(C,I.trystat(k),bprettyprintformat,I.trystat(k+1));
+            end
+        end
+        C = format_txt(C,I.trystat($),bprettyprintformat); // Add EOL after last statement if needed
+        C=cat_code(C,"catch ")
+        for k=1:size(I.catchstat)
+            C=cat_code(C,indent_space+instruction2code(I.catchstat(k)))
+            if k<size(I.catchstat) then // Add EOL between statements if needed
+                C = format_txt(C,I.catchstat(k),bprettyprintformat,I.catchstat(k+1));
+            end
+        end
+        C = format_txt(C,I.catchstat($),bprettyprintformat); // Add EOL after last statement if needed
+        C=cat_code(C,"end")
+        C($)=C($)+";"
+        return
+    end
+
+    // ---------------------------------------------
+    // Generate code corresponding to a IF-THEN-ELSE
+    // ---------------------------------------------
+    if typeof(I)=="ifthenelse" then
+
+        // IF
+        C="if "+expression2code(I.expression)+" then"
+        [C,indent_space] = format_txt(C,I.then(1),bprettyprintformat); // Add EOL after then if needed and returns indent_space
+        for k=1:size(I.then)
+            C=cat_code(C,indent_space+instruction2code(I.then(k)))
+            if k<size(I.then) then // Add EOL between then statements if needed
+                C = format_txt(C,I.then(k),bprettyprintformat,I.then(k+1));
+            end
+        end
+        C = format_txt(C,I.then($),bprettyprintformat); // Add EOL after last then statement if needed
+
+        // ELSEIF
+        if size(I.elseifs)<>0 then
+            for k=1:size(I.elseifs)
+                C=cat_code(C,"elseif "+expression2code(I.elseifs(k).expression)+" then")
+                [C,indent_space] = format_txt(C,I.elseifs(k).then(1),bprettyprintformat); // Add EOL after then if needed and returns indent_space
+                for l=1:size(I.elseifs(k).then)
+                    C=cat_code(C,indent_space+instruction2code(I.elseifs(k).then(l)))
+                    if l<size(I.elseifs(k).then) then // Add EOL between then statements
+                        C = format_txt(C,I.elseifs(k).then(l),bprettyprintformat,I.elseifs(k).then(l+1));
+                    end
+                end
+                C = format_txt(C,I.elseifs(k).then($),bprettyprintformat); // Add EOL after last then statement if needed
+            end
+        end
+
+        // ELSE
+        if size(I.else)<>0 then
+            C=cat_code(C,"else")
+        [C,indent_space] = format_txt(C,I.else(1),bprettyprintformat); // Add EOL after else if needed and returns indent_space
+            for k=1:size(I.else)
+            C=cat_code(C,indent_space+instruction2code(I.else(k)))
+                if k<size(I.else) then // Add EOL between else statements if needed
+                C = format_txt(C,I.else(k),bprettyprintformat,I.else(k+1));
+                end
+            end
+        C = format_txt(C,I.else($),bprettyprintformat); // Add EOL after last else statement if needed
+        end
+        C=cat_code(C,"end")
+        C($)=C($)+";"
+        return
+    end
+
+    // --------------------------------------------
+    // Generate code corresponding to a SELECT-CASE
+    // --------------------------------------------
+    if typeof(I)=="selectcase" then
+
+        // SELECT
+        C="select "+expression2code(I.expression(1))
+
+        if size(I.expression)==1 // Not EOL and not comment after the expression
+            if bprettyprintformat then
+                C = cat_code(C,"") // Add EOL after expression
+            end
+        else
+            for i=2:size(I.expression)
+                C=cat_code(C," "+ instruction2code(I.expression(i)))
+            end
+        end
+
+        // CASES
+        if size(I.cases)<>0 then
+            for k=1:size(I.cases)
+                C=cat_code(C,"  case "+expression2code(I.cases(k).expression)+" then")
+                [C,indent_space] = format_txt(C,I.cases(k).then(1),bprettyprintformat); // Add EOL after then if needed and returns indent_space
+                if indent_space=="  " then // indent_space is modified because indentation differs from others control instructions
+                    indent_space="    "
+                end
+                for l=1:size(I.cases(k).then)
+                    C=cat_code(C,indent_space+instruction2code(I.cases(k).then(l)))
+                    if l<size(I.cases(k).then) then // Add EOL between then statements if needed
+                        C = format_txt(C,I.cases(k).then(l),bprettyprintformat,I.cases(k).then(l+1));
+                    end
+                end
+                C = format_txt(C,I.cases(k).then($),bprettyprintformat); // Add EOL after last then statement if needed
+            end
+        end
+        // ELSE
+        if size(I.else)<>0 then
+            C=cat_code(C,"  else")
+        [C,indent_space] = format_txt(C,I.else(1),bprettyprintformat); // Add EOL after else if needed and returns indent_space
+            if indent_space=="  " then // indent_space is modified because indentation differs from others control instructions
+                indent_space="    "
+            end
+            for k=1:size(I.else)
+            C=cat_code(C,indent_space+instruction2code(I.else(k)))
+                if k<size(I.else) then // Add EOL between else statements if needed
+                C = format_txt(C,I.else(k),bprettyprintformat,I.else(k+1));
+                end
+            end
+        C = format_txt(C,I.else($),bprettyprintformat); // Add EOL after last else statement if needed
+        end
+        C=cat_code(C,"end")
+        C($)=C($)+";"
+        return
+    end
+
+    // --------------------------------------
+    // Generate code corresponding to a WHILE
+    // --------------------------------------
+    if typeof(I)=="while" then
+
+        C="while "+expression2code(I.expression)
+        [C,indent_space] = format_txt(C,I.statements(1),bprettyprintformat); // Add EOL after while if needed and returns indent_space
+        for k=1:size(I.statements)
+            C=cat_code(C,indent_space+instruction2code(I.statements(k)))
+            if k<size(I.statements) then // Add EOL between statements if needed
+                C = format_txt(C,I.statements(k),bprettyprintformat,I.statements(k+1));
+            end
+        end
+        C = format_txt(C,I.statements($),bprettyprintformat); // Add EOL after last statement if needed
+        C=cat_code(C,"end")
+        C($)=C($)+";"
+        return
+    end
+
+    // ------------------------------------
+    // Generate code corresponding to a FOR
+    // ------------------------------------
+    if typeof(I)=="for" then
+
+        C="for "+instruction2code(I.expression)
+        [C,indent_space] = format_txt(C,I.statements(1),bprettyprintformat); // Add EOL after while if needed and returns indent_space
+        for k=1:size(I.statements)
+            C=cat_code(C,indent_space+instruction2code(I.statements(k)))
+            if k<size(I.statements) then // Add EOL between statements if needed
+                C = format_txt(C,I.statements(k),bprettyprintformat,I.statements(k+1));
+            end
+        end
+        C = format_txt(C,I.statements($),bprettyprintformat); // Add EOL after last statement if needed
+        C=cat_code(C,"end")
+        C($)=C($)+";"
+        return
+    end
+
+    // --------------------------------------
+    // Generate code corresponding to a EQUAL
+    // --------------------------------------
+    if typeof(I)=="equal" then
+
+        // Comments
+        if typeof(I.expression)=="funcall" then
+            if I.expression.name=="%comment" then
+                I.expression.rhs(1).value=strsubst(I.expression.rhs(1).value,"""""","""")
+                I.expression.rhs(1).value=strsubst(I.expression.rhs(1).value,"''''","''")
+                C="//"+I.expression.rhs(1).value
+                //C($)=C($)+";"
+                return
+            end
+        end
+
+        // Other EQUAL instruction
+        if size(I.lhs)==1 then
+            if typeof(I.lhs(1))=="variable" then
+                if I.lhs(1).name=="ans" then // expression
+                    C=rhs2code(I.expression)
+                else
+                    RHS=rhs2code(I.expression)
+                    if size(RHS,"*")==1 then
+                        C=I.lhs(1).name+" = "+rhs2code(I.expression)
+                    else // Multi-line definition
+                        C=[I.lhs(1).name+" = "+RHS(1);"     "+RHS(2:$)]
+                    end
+                end
+            else // Insertion...
+                C=expression2code(I.lhs(1))+" = "+rhs2code(I.expression)
+            end
+        else
+            lhsnames=[]
+            for lhsind=1:size(I.lhs)
+                lhsnames=[lhsnames,expression2code(I.lhs(lhsind))]
+            end
+            if strcat(lhsnames,",")<>"" then
+                C="["+strcat(lhsnames,",")+"] = "+rhs2code(I.expression)
+            else
+                C=rhs2code(I.expression)
+            end
+        end
+        C($)=C($)+I.endsymbol
+        //C($)=C($)+";";
+        return
+    end
+
+    // --------------------------------------
+    // Generate code corresponding to a comment
+    // --------------------------------------
+    if typeof(I)=="comment" then
+        C="//"+I.text
+        //C = cat_code(C,"//"+I.text)
+        return
+    end
+
+    // ---------------------------------------
+    // Generate code corresponding to sup_equal
+    // ---------------------------------------
+    if typeof(I)=="sup_equal" then
+        while typeof(I.sup_instr(1))=="equal" | I.sup_instr(1)==list("EOL")
+            if I.sup_instr(1)==list("EOL") then //Instruction is an EOL
+                I.sup_instr(1)=null()
+            elseif typeof(I.sup_instr(1))=="equal" then //Instruction is acomment
+                if typeof(I.sup_instr(1).expression)=="funcall" then
+                    break
+                end
+            end
+        end
+        //Optimize the code if all sup_intr are equal tlists and expression of this equal tlists are temporaries variables (not a function)
+        if size(I.sup_instr)==I.nb_opr+1 then
+            for i=size(I.sup_instr):-1:2
+                optim_instr=%f
+                if typeof(I.sup_instr(i))=="equal" then
+                    if typeof(I.sup_instr(i).expression)=="variable" then
+                        j=0
+                        while ~optim_instr & j<=size(I.sup_instr(1).lhs)
+                            j=j+1
+                            optim_instr=I.sup_instr(i).expression.name==I.sup_instr(1).lhs(j).name
+                        end
+                    end
+                end
+                if optim_instr then
+                    I.sup_instr(1).lhs(j)=I.sup_instr(i).lhs(1)
+                    I.sup_instr(i)=null()
+                end
+            end
+        end
+        for i=1:size(I.sup_instr)
+            C($+1)=instruction2code(I.sup_instr(i))
+        end
+        return
+    end
+
+    // ----------------------------------------------------
+    // Generate code corresponding to a function definition
+    // ----------------------------------------------------
+    if typeof(I)=="inline" then
+        C = "function "+I.prototype;
+        C = cat_code(C,I.definition)
+        C($+1) = "endfunction";
+        return
+    end
+
+    // -------
+    // Command
+    // -------
+    if and(typeof(I)<>["funcall" "variable", "comment"]) then
+        disp("instruction2code: bug in macr2tree() !");
+        pause
+    end
+    C=expression2code(I);
+    C($)=C($)+";"
+endfunction
+
diff --git a/modules/string/macros/justify.bin b/modules/string/macros/justify.bin
new file mode 100755
index 000000000..56f4e7c4b
Binary files /dev/null and b/modules/string/macros/justify.bin differ
diff --git a/modules/string/macros/justify.sci b/modules/string/macros/justify.sci
new file mode 100755
index 000000000..3069c97df
--- /dev/null
+++ b/modules/string/macros/justify.sci
@@ -0,0 +1,73 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA -
+// Copyright (C) DIGITEO - 2010 - Pierre Marechal
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function t = justify(t, job)
+
+    // Check input parameters
+    // =========================================================================
+
+    rhs = argn(2);
+
+    if rhs <> 2 then
+        error(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"justify",2))
+    end
+
+    if t == [] then
+        t = [];
+        return;
+    end
+    if type(t) <> 10 then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "justify", 1));
+    end
+
+    if type(job) <> 10 then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "justify", 2));
+    end
+
+    if size(job,"*") <> 1 then
+        error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "justify", 2));
+    end
+
+    if and(job <> ["l" "c" "r" "left" "center" "right"]) then
+        error(msprintf(gettext("%s: Wrong value for input argument #%d: ""%s"", ""%s"" or ""%s"" expected.\n"), "justify", 2,"r","l","c"));
+        //  "left,center & right" are just here for backward compatibility
+    end
+
+    // Redefine the wanted justification
+    // =========================================================================
+    job = part(job, 1);
+
+    // Remove leading and trailing whitespaces (See bug #7751)
+    // =========================================================================
+    t = stripblanks(t);
+
+    //Justify character array.
+    [m, n] = size(t);
+
+    for k = 1:n
+        L  = length(t(:,k));
+        mx = max(L);
+        if job == "l" then           //right
+            t(:,k) = part(t(:,k),1:mx)
+        elseif job == "r" then       //left
+            for l = 1:m
+                t(l,k) = part(" ", 1:(mx-length(t(l,k)))) + t(l, k);
+            end
+        elseif job == "c" then       //center
+            for l = 1:m
+                nl = int((mx - length(t(l, k)))/2)
+                nr = (mx - length(t(l, k))) - nl
+                t(l, k) = part(" ", 1:nl) + t(l, k) + part(" ", 1:nr);
+            end
+        end
+    end
+
+endfunction
diff --git a/modules/string/macros/lib b/modules/string/macros/lib
new file mode 100755
index 000000000..ac2b113e8
Binary files /dev/null and b/modules/string/macros/lib differ
diff --git a/modules/string/macros/names b/modules/string/macros/names
new file mode 100755
index 000000000..09a555cb4
--- /dev/null
+++ b/modules/string/macros/names
@@ -0,0 +1,21 @@
+%_strsplit
+%ip_part
+%mc_string
+%p_part
+%plist_string
+arobasestring2strings
+ascii2string
+asciimat
+blanks
+cat_code
+eval
+evstr
+expression2code
+format_txt
+instruction2code
+justify
+rhs2code
+sci2exp
+strcmpi
+tokenpos
+tree2code
diff --git a/modules/string/macros/rhs2code.bin b/modules/string/macros/rhs2code.bin
new file mode 100755
index 000000000..c4e1c8820
Binary files /dev/null and b/modules/string/macros/rhs2code.bin differ
diff --git a/modules/string/macros/rhs2code.sci b/modules/string/macros/rhs2code.sci
new file mode 100755
index 000000000..12cad62a7
--- /dev/null
+++ b/modules/string/macros/rhs2code.sci
@@ -0,0 +1,50 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Vincent Couvert
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function C=rhs2code(rhs)
+    // Translate rhs list of an instruction to macro code (called by tree2code)
+    // Input:
+    // - rhs: list of rhs arguments
+    // Output:
+    // - C: Scilab code corresponding to rhs
+    // V.C.
+
+    n=size(rhs)
+
+    C=""
+    if typeof(rhs)<>"list" then
+        C=expression2code(rhs)
+    else
+        for k=1:n
+            therhs = expression2code(rhs(k));
+            if k==1 then
+                C = therhs;
+            else
+                if therhs == "(EOL)" then
+                    C = [C;""];
+                else
+                    if C($)=="" then
+                        // Previous rhs was a EOL
+                        C = [C(1:($-2));
+                        C($-1)+"..";
+                        C($) + therhs(1);
+                        therhs(2:$)];
+                    else
+                        C = [C(1:($-1));
+                        C($) + "," + therhs(1);
+                        therhs(2:$)];
+                    end
+                end
+            end
+        end
+    end
+
+
+endfunction
diff --git a/modules/string/macros/sci2exp.bin b/modules/string/macros/sci2exp.bin
new file mode 100755
index 000000000..e39be5e1a
Binary files /dev/null and b/modules/string/macros/sci2exp.bin differ
diff --git a/modules/string/macros/sci2exp.sci b/modules/string/macros/sci2exp.sci
new file mode 100755
index 000000000..37378018e
--- /dev/null
+++ b/modules/string/macros/sci2exp.sci
@@ -0,0 +1,818 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA -
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function t=sci2exp(a,nom,lmax)
+    // sci2exp - convert a variable to an expression
+    //%SYNTAX
+    // t=sci2exp(a [,nam] [,lmax])
+    //%PARAMETERS
+    //   a  : matrix of scalar or polynomials
+    //   nam: character string
+    //   t  : vector of string, contains the expression definition
+    //   lmax : maximum line lengh (0 for no line length control)
+    //%Example
+    //  a=[1 2;3 4]
+    //  sci2exp(a,'aa')
+    //!
+
+    deff("x=String(a)",["x=string(a)"
+    "x=strsubst(x,''Nan'',''%nan'')"
+    "x=strsubst(x,''Inf'',''%inf'')"
+    ])
+
+
+    [lhs,rhs]=argn(0)
+    $ // import global variable $ in sci2exp context for efficiency
+    select rhs
+    case 1 then
+        named=%f
+        lmax=0
+    case 2 then
+        if type(nom)==1 then
+            lmax=nom
+            named=%f
+        else
+            named=%t
+            lmax=0
+        end
+    case 3 then
+        named=%t
+        if type(nom)==1 then
+            [lmax,nom]=(nom,lmax)
+        end
+    end
+    dots="..";
+    select type(a)
+    case 1 then
+        t=mat2exp(a,lmax)
+    case 2 then
+        t=pol2exp(a,lmax)
+    case 4 then
+        t=log2exp(a,lmax)
+    case 5 then
+        t=sp2exp(a,lmax)
+    case 6 then
+        t=sp2exp(a,lmax)
+    case 7 then
+        t=sp2exp(a,lmax)
+    case 8 then
+        t=int2exp(a,lmax)
+    case 9 then
+        t=h2exp(a, lmax)
+    case 10 then
+        t=str2exp(a,lmax)
+    case 13 then
+        if named then
+            t=fun2string(a,nom)
+        else
+            t=fun2string(a,"%fun")
+        end
+        t(1)=part(t(1),10:length(t(1)))
+        t($)=[]
+        t=sci2exp(t,lmax)
+        t(1)="createfun("+t(1)
+        t($)=t($)+")"
+    case 15 then
+        t=list2exp(a,lmax)
+    case 16 then
+        t=tlist2exp(a,lmax)
+    case 17 then
+        t=mlist2exp(a,lmax)
+    case 11 then
+        t=func2exp(a,lmax)
+        named=%f
+    case 129 then
+        t=imp2exp(a,lmax)
+    else
+        //  execstr('t='+typeof(a)+'2exp(a,lmax)')
+        error(msprintf(gettext("%s: This feature has not been implemented: Variable translation of type %s.\n"),"sci2exp",string(type(a))));
+    end,
+    if named&and(type(a)<>[11 13]) then
+        t(1)=nom+" = "+t(1)
+    end
+endfunction
+
+function t=str2exp(a,lmax)
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+
+    [m,n]=size(a),
+    dots="."+"."
+    t=[];
+    quote="''"
+
+    a=strsubst(a,quote,quote+quote)
+    dquote=""""
+    a=strsubst(a,dquote,dquote+dquote)
+    a = strsubst(a, ascii(10), """+ascii(10)+""")
+    a=quote(ones(a))+a+quote(ones(a))
+
+    for i=1:m
+        x=emptystr();
+        for j=1:n,
+            y=a(i,j);
+            y=dquote+part(y,2:length(y))
+            y=part(y,1:length(y)-1)+dquote
+            if y=="''''" then y="emptystr()",end
+            if lmax==0|length(x($))+length(y)<lmax then
+                if j==1 then
+                    x=y
+                else
+                    x($)=x($)+","+y,
+                end
+            else
+                if j>1 then
+                    x($)=x($)+","+dots;
+                    x($+1)=y
+                else
+                    x=y
+                end
+            end
+        end
+        if i<m then x($)=x($)+";",end
+        if lmax>0 then
+            t=[t;x]
+        else
+            t=t+x
+        end
+    end,
+    if lmax>0&sum(length(t))<lmax then
+        t=strcat(t)
+    end
+    if m*n>1 then
+        t(1)="["+t(1)
+        t($)=t($)+"]"
+    end
+endfunction
+
+function t=mat2exp(a,lmax)
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    if size(a,"*")==0 then t="[]",return,end
+    [m,n]=size(a);
+    if m<0 then
+        t=mat2exp(a+0);
+        if t=="1" then
+            t="eye()";
+        else
+            t="("+t+")*eye()";
+        end
+        return
+    end
+    a=String(a);
+    dots="."+"."
+    t=[];
+    if n==1 then
+        x=strcat(a,";")
+        lx=length(x)
+        if lmax==0|lx<lmax then
+            t=x;
+        else
+            ind=strindex(x,";");
+            k1=1;l=0;I=[];
+            while %t
+                if lx-l<lmax|k1>length(ind) then,break,end
+                k2=k1-1+max(find(ind(k1:$)<l+lmax))
+                I=[I ind(k2)];
+                //	t=[t;part(x,l+1:ind(k2))]
+                k1=k2+1
+                l=ind(k2)
+            end
+            t=[t;strsplit(x,I)];
+        end
+    elseif m==1 then
+        x=strcat(a,",")
+        lx=length(x)
+        if lmax==0|lx<lmax then
+            t=x;
+
+        else
+            ind=strindex(x,",");
+            k1=1;l=0;I=[];
+            while %t
+                if lx-l<lmax|k1>length(ind) then break,end
+                k2=k1-1+max(find(ind(k1:$)<l+lmax))
+                I=[I ind(k2)];
+                //	t=[t;part(x,l+1:ind(k2))+dots]
+                k1=k2+1
+                l=ind(k2)
+            end
+            x=strsplit(x,I);x(1:$-1)=x(1:$-1)+dots;
+            t=[t;x]
+        end
+    else
+        for i=1:m
+            x=strcat(a(i,:),",")
+            if i<m then x=x+";",end
+            lx=length(x)
+            if lmax==0 then
+                t=t+x
+            elseif lx<lmax then
+                t=[t;x]
+            else
+                ind=strindex(x,",");
+                k1=1;l=0;I=[];
+                while %t
+                    if lx-l<lmax|k1>length(ind) then break,end
+                    k2=k1-1+max(find(ind(k1:$)<l+lmax))
+                    I=[I ind(k2)];
+                    //	  t=[t;part(x,l+1:ind(k2))+dots]
+                    k1=k2+1
+                    l=ind(k2)
+                end
+                x=strsplit(x,I);x(1:$-1)=x(1:$-1)+dots;x(2:$)=" "+x(2:$);
+                t=[t;x]
+            end
+        end
+    end
+    if m*n>1 then
+        t(1)="["+t(1)
+        t($)=t($)+"]"
+    end
+endfunction
+
+function t=pol2exp(a,lmax)
+    $
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+
+    [m,n]=size(a),var=" ";lvar=1
+    var=varn(a),lvar=length(var);
+    while part(var,lvar)==" " then lvar=lvar-1,end
+    var=part(var,1:lvar);
+    if m<0 then
+        t=pol2exp(a+0)
+        t="("+t+")*eye()"
+        return
+    end
+    t=[];
+    for i=1:m
+        x=emptystr(1)
+        for j=1:n,
+            v=a(i,j);d=degree(v);
+            v=coeff(v);
+            k0=1;while (k0<d+1)&(v(k0))==0 then k0=k0+1,end
+            y=emptystr(1)
+            nul=%t
+            for k=k0:(d+1),
+                s=String(v(k))
+                if s<>"0" then
+                    nul=%f
+                    if part(s,1)==" " then s=part(s,2:length(s)),end
+                    mnm=emptystr(1)
+                    if k>0 then
+                        mnm=var
+                        if k>2 then
+                            mnm=mnm+"^"+string(k-1),
+                        end
+                    end
+                    if k>1 then
+                        if string(imag(v(k)))<>"0" then s="("+s+")",end
+                        if s=="1" then
+                            s=mnm
+                        elseif s=="-1" then
+                            s="-"+mnm
+                        else
+                            s=s+"*"+mnm
+                        end
+                        if k>k0&part(s,1)<>"-" then s="+"+s,end
+                    end
+                    if lmax==0|length(y($))+length(s) <lmax then
+                        y($)=y($)+s
+                    else
+                        y($)=y($)+dots
+                        y($+1)=s
+                    end
+                end
+            end
+            if nul then y="0*"+var,end
+            [ny,my]=size(y)
+
+            if lmax==0|length(x($))+length(y(1))<lmax then
+                if j==1 then
+                    x=y(1)
+                else
+                    x($)=x($)+","+y(1),
+                end
+                if ny>1 then x($+1:$+ny-1)=y(2:ny),end
+            else
+                if length(x($))==0 then
+                    x($:$+ny-1) = y;
+                else
+                    x($)=x($)+","+dots;
+                    x($+1:$+ny)=y
+                end
+            end
+        end
+        if i<m then x($)=x($)+";",end
+        if lmax>0 then
+            t=[t;x]
+        else
+            t=t+x
+        end
+    end,
+    if lmax>0&sum(length(t))<lmax then
+        t=strcat(t)
+    end
+    if m*n>1 then
+        t(1)="["+t(1)
+        t($)=t($)+"]"
+    end
+endfunction
+
+function t=list2exp(l,lmax)
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    dots="."+".";
+    t="list("
+    n=length(l)
+    for k=1:n
+        lk=l(k)
+        sep=",",if k==1 then sep=emptystr(),end
+        if type(lk)==9 then
+            t1=h2exp(lk,lmax)
+        elseif type(lk)==15 then
+            t1=list2exp(lk,lmax)
+        elseif type(lk)==16 then
+            t1=tlist2exp(lk,lmax)
+        elseif type(lk)==17 then
+            t1=mlist2exp(lk,lmax)
+        else
+            t1=sci2exp(lk,lmax)
+        end
+        if size(t1,"*")==1&(lmax==0|max(length(t1))+length(t($))<lmax) then
+            t($)=t($)+sep+t1
+        else
+            t($)=t($)+sep+dots
+            t=[t;t1]
+        end
+        lk=null()
+    end
+    t($)=t($)+")"
+endfunction
+
+function t=tlist2exp(l,lmax)
+    $;
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    dots="."+".";
+    t="tlist("
+    n=length(l)
+    for k=1:n
+        lk=l(k)
+        sep=",",if k==1 then sep=emptystr(),end
+        if type(lk)==15 then
+            t1=list2exp(lk,lmax)
+        elseif type(lk)==16 then
+            t1=tlist2exp(lk,lmax)
+        elseif type(lk)==17 then
+            t1=mlist2exp(lk,lmax)
+        elseif type(lk)==9 then
+            t1=h2exp(lk,lmax,1)
+        else
+            t1=sci2exp(lk,lmax)
+        end
+        if size(t1,"*")==1&(lmax==0|max(length(t1))+length(t($))<lmax) then
+            t($)=t($)+sep+t1
+        else
+            t($)=t($)+sep+dots
+            t=[t;t1]
+        end
+    end
+    t($)=t($)+")"
+
+endfunction
+
+function t=mlist2exp(l,lmax)
+    $;
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    dots="."+".";
+    t="mlist("
+    n=size(definedfields(l),"*")
+    for k=1:n
+        lk=getfield(k,l)
+        sep=",",if k==1 then sep=emptystr(),end
+        if type(lk)==15 then
+            t1=list2exp(lk,lmax)
+        elseif type(lk)==16 then
+            t1=tlist2exp(lk,lmax)
+        elseif type(lk)==17 then
+            t1=mlist2exp(lk,lmax)
+        elseif type(lk)==9 then
+            t1=h2exp(lk,lmax)
+        else
+            t1=sci2exp(lk,lmax)
+        end
+        if size(t1,"*")==1&(lmax==0|max(length(t1))+length(t($))<lmax) then
+            t($)=t($)+sep+t1
+        else
+            t($)=t($)+sep+dots
+            t=[t;t1]
+        end
+    end
+    t($)=t($)+")"
+
+endfunction
+
+function t=log2exp(a,lmax)
+    $;
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    [m,n]=size(a),
+    a1=matrix(a,m*n,1)
+    F="%f"
+    T="%t"
+    a=F(ones(m*n,1))
+    k=find(a1);
+    if k<>[] then
+        a(k)=T(ones(size(k,"*"),1));
+    end
+    a=matrix(a,m,n);
+    dots="."+"."
+    t=[];
+    for i=1:m
+        x=emptystr()
+        for j=1:n,
+            y=a(i,j);
+            if lmax==0|length(x($))+length(y)<lmax then
+                if j==1 then
+                    x=y
+                else
+                    x($)=x($)+","+y,
+                end
+            else
+                x($)=x($)+","+dots;
+                x($+1)=y
+            end
+        end
+        t=[t;x]
+    end,
+    if lmax==0|lmax>0&sum(length(t))<lmax then
+        t=strcat(t,";")
+    end
+    if m*n>1 then
+        t(1)="["+t(1)
+        t($)=t($)+"]"
+    end
+
+endfunction
+
+function t=func2exp(a,lmax)
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    [out,in,text]=string(a)
+    if out==[] then out=emptystr(),end
+    text=str2exp(text,lmax)
+    nt=size(text,"*")
+    if named then mac=nom,else mac="mac",end
+    if nt==1 then
+        t="deff(''["+strcat(out,",")+"]="+mac+"("+strcat(in,",")+")'',"+text+")"
+    else
+        text($)=text($)+")"
+        semi=";"
+        text(1:$-1)=text(1:$-1)+semi(ones(nt-1,1))'
+        t=["deff(''["+strcat(out,",")+"]="+mac+"("+strcat(in,",")+")'',"+text(1)
+        text(2:$)]
+    end
+endfunction
+
+function t=imp2exp(a,lmax)
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    v=[a(1),a(2),a(3)]
+    if a(2)==1 then
+        t=sci2exp(a(1))+":"+sci2exp(a(3))
+    else
+        t=sci2exp(a(1))+":"+sci2exp(a(2))+":"+sci2exp(a(3))
+    end
+endfunction
+
+function t=sp2exp(a,lmax)
+    if rhs<2 then lmax=0,end
+    [lhs,rhs]=argn(0)
+    dots="..";
+    [ij,v,mn]=spget(a)
+    t=sci2exp(ij,lmax)
+    v=sci2exp(v,lmax)
+    mn=sci2exp(mn,lmax)
+
+    t(1)="sparse("+t(1)
+    if lmax==0|length(t($))+length(v(1))+1<lmax then
+        t($)=t($)+","+v(1)
+        t=[t;v(2:$)]
+    else
+        t($)=t($)+","+dots
+        t=[t;v]
+    end
+    if lmax==0|length(t($))+length(mn(1))+1<lmax then
+        t($)=t($)+","+mn(1)
+        t=[t;mn(2:$)]
+    else
+        t($)=t($)+","+dots
+        t=[t;mn]
+    end
+    t($)=t($)+")"
+endfunction
+
+
+function t=int2exp(a,lmax)
+    it=inttype(a)
+    if it>10 then f="uint",else f="int",end
+    f=f+string(8*modulo(it,10))
+    t=mat2exp(double(a),lmax)
+    t(1)=f+"("+t(1)
+    t($)=t($)+")"
+endfunction
+
+
+function t=h2exp(a,lmax) //Only for figure and uicontrol
+    $;
+    if rhs<2 then lmax=0
+    end
+    [lhs,rhs]=argn(0);
+
+
+    f1="''parent'', ";
+    f2="''children'', ";
+    f3="''BackgroundColor'', ";
+    f4="''Enable'', ";
+    f5="''fontAngle'', ";
+    f6="''fontName'', ";
+    f7="''fontSize'', ";
+    f8="''fontUnits'', ";
+    f9="''fontWeight'', ";
+    f10="''ForegroundColor'', ";
+    f11="''HorizontalAlignment'', ";
+    f12="''ListboxTop'', ";
+    f13="''Max'', ";
+    f14="''Min'', ";
+    f15="''Position'', ";
+    f16="''Relief'', ";
+    f17="''SliderStep'', ";
+    f18="''String'', ";
+    f19="''Style'', ";
+    f20="''TooltipString'', ";
+    f21="''Units'', ";
+    f22="''Value'', ";
+    f23="''VerticalAlignment'', ";
+    f24="''Visible'', ";
+    f25="''Callback'', ";
+    f26="''Callback_Type'', ";
+    f27="''Handle_Visible'', ";
+    f28="''Userdata'', ";
+    f29="''Tag'', ";
+    f30="''figure_position'', ";
+    f31="''figure_size'', ";
+    f32="''axes_size'', ";
+    f33="''auto_resize'', ";
+    f34="''viewport'', ";
+    f35="''figure_name'', ";
+    f36="''figure_id'', ";
+    f37="''info_message'', ";
+    f38="''color_map'', ";
+    f40="''pixel_drawing_mode'', ";
+    f41="''anti_aliasing'', ";
+    f42="''immediate_drawing'', ";
+    f43="''background'', ";
+    f44="''rotation_style'', ";
+    f45="''event_handler'', ";
+    f46="''event_handler_enable'', ";
+    f47="''resizefcn'', ";
+    f48="''closerequestfcn'', ";
+    x=[];
+
+
+    if a.type=="uicontrol"
+        f="uicontrol";
+        if a.BackgroundColor <> [0.8 0.8 0.8] then
+            if type(a.BackgroundColor)==1 then
+                f3_strg=String(a.Backgroundcolor);
+                f3_strg="["+f3_strg(1)+" "+f3_strg(2)+" "+f3_strg(3)+"]";
+                x=x+f3+f3_strg+", ";
+            else
+                f3_strg=a.BackgroundColor;
+                x=x+f3+"''"+f3_strg+"''"+", ";
+            end
+        end
+        if a.Enable <> "on" then x=x+f4+"''"+a.Enable+"''"+", "; end
+        if a.fontAngle <> "normal" then x=x+f5+"''"+a.fontAngle+"''"+", "; end
+        if a.fontName <> "helvetica" then x=x+f6+"''"+a.fontName+"''"+", "; end
+        f7_strg=String(a.fontSize);
+        if a.fontSize <> 10 then x=x+f7+f7_strg+", "; end
+        if a.fontUnits <> "points" then x=x+f8+"''"+a.fontUnits+"''"+", "; end
+        if a.fontWeight <> "normal" then x=x+f9+"''"+a.fontWeight+"''"+", "; end
+        if a.foregroundColor <>[0 0 0] then
+            if type(a.ForegroundColor)==1 then
+                f10_strg=String(a.foregroundColor);
+                f10_strg="["+f10_strg(1)+" "+f10_strg(2)+" "+f10_strg(3)+"]";
+                x=x+f10+f10_strg+" ,";
+            else
+                f10_strg=a.ForegroundColor;
+                x=x+f10+"''"+f10_strg+"''"+", ";
+            end
+        end
+        if a.HorizontalAlignment <> "center" then x=x+f11+"''"+a.horizontalAlignment+"''"+", "; end
+        f12_strg=String(a.ListBoxTop);
+        if a.ListBoxTop <>[] then x=x+f12+f12_strg+", "; end
+        f13_strg=String(a.Max);
+        if a.max<> 1 then x=x+f13+f13_strg+", "; end
+        f14_strg=String(a.Min);
+        if a.min<> 0 then x=x+f14+f14_strg+", "; end
+        if a.Position <>[20 40 40 20] then
+            if type(a.Position)==1 then
+                f15_strg=String(a.Position);
+                f15_strg="["+f15_strg(1)+" "+f15_strg(2)+" "+f15_strg(3)+" "+f15_strg(4)+"]";
+                x=x+f15+f15_strg+", ";
+            else
+                f15_strg=a.Position;
+                x=x+f15+"''"+f15_strg+"''"+", ";
+            end
+        end
+        x=x+f16+"''"+a.Relief+"''"+", ";
+        f17_strg=String(a.sliderStep); f17_strg="["+f17_strg(1)+" "+f17_strg(2)+"]";
+        if a.sliderStep <> [0.01 0.1] then x=x+f17+f17_strg+", "; end
+        if a.String <>"" then x=x+f18+"''"+a.String+"''"+" ,"; end
+        if a.Style <> "pushbutton" then x=x+f19+"''"+a.Style+"''"+", "; end
+        if a.TooltipString <> "" then x=x+f20+"''"+a.TooltipString+"''"+", "; end
+        if a.Units <> "pixels" then x=x+f21+"''"+a.Units+"''"+", "; end
+        if a.Value<>[] then
+            f22_strg=String(a.value);
+            f22l=length(a.value);
+            for i=1:f22l
+                f22_strg=strcat(f22_strg, ",");
+                f22_strg="["+f22_strg+"]";
+            end
+            x=x+f22+", "+f22_strg+", ";
+        end
+        if a.VerticalAlignment <> "middle" then x=x+f23+"''"+a.VerticalAlignment+"''"+", "; end
+        if a.Visible <> "on" then x=x+f24+"''"+a.Visible+"''"+", "; end
+        if a.Callback <>"" then x=x+f25+"''"+a.Callback+"''"+" ,"; end
+        f26_strg=String(a.Callback_Type);
+        if a.Callback_Type <> -1 then x=x+f26+f26_strg+", "; end
+        if a.Handle_Visible <> "on" then x=x+f27+"''"+a.Handle_Visible+"''"+", "; end
+        if a.Userdata <>[] then
+            if type(a.userdata) == 1 then
+                f28_strg=mat2exp(a.userdata,0)
+            elseif type(a.userdata) == 2 then
+                f28_strg=pol2exp(a.userdata,0)
+            elseif type(a.userdata) == 4 then
+                f28_strg=log2exp(a.userdata,0)
+            elseif type(a.userdata) == 5 | type(a.userdata) == 6 | type(a.userdata) == 7 then
+                f28_strg=sp2exp(a.userdata,0)
+            elseif type(a.userdata) == 8 then
+                f28_strg=int2exp(a.userdata,0)
+            elseif type(a.userdata) == 9 then
+                f28_strg=h2exp(a.userdata,0)
+            elseif type(a.userdata) == 10 then
+                f28_strg=str2exp(a.userdata,0)
+            elseif type(a.userdata) == 11 then
+                f28_strg=func2exp(a.userdata,0)
+                named=%f
+            elseif type(a.userdata) == 13 then
+                if named then
+                    t=fun2string(a,nom)
+                else
+                    t=fun2string(a,"%fun")
+                end
+                t(1)=part(t(1),10:length(t(1)))
+                t($)=[]
+                t=sci2exp(t,lmax)
+                t(1)="createfun("+t(1)
+                t($)=t($)+")"
+            elseif type(a.userdata) == 15 then
+                f28_strg=list2exp(a.userdata);
+            elseif type(a.userdata) == 16 then
+                f28_strg=tlist2exp(a.userdata,0);
+            elseif type(a.userdata) == 17 then
+                f28_strg=mlist2exp(a.userdata,0);
+            elseif type(a.userdata) == 129 then
+                f28_strg=imp2exp(a.userdata,0);
+            end
+            x=x+f28+f28_strg+", ";
+        end
+        if a.Tag<>"" then x=x+f29+"''"+a.Tag+"''"+", "; end
+        lx=length(x);
+        x=part(x,1:lx-2);
+        t(1)=f+"("+x;
+        t(1)=t(1)+")";
+        dots="."+".";
+        lt=length(t(1))
+        if lt>lmax & lmax<>0 then
+            ind=strindex(x,",");
+            k1=1;l=0;I=[];
+            while %t
+                if lt-l<lmax|k1>length(ind) then break,end
+                k2=k1-1+max(find(ind(k1:$)<l+lmax))
+                I=[I ind(k2)];
+                k1=k2+1
+                l=ind(k2)
+            end
+            t=strsplit(t(1),I);
+            t(1:$-1)=t(1:$-1)+dots;
+        end
+
+
+    elseif a.type == "Figure" then
+        f="figure";
+        f30_strg=String(a.figure_position);
+        f30_strg="["+f30_strg(1)+" "+f30_strg(2)+"]";
+        if a.figure_position <> [] then x=f30+f30_strg+", "; end
+        f31_strg=String(a.figure_size);
+        f31_strg="["+f31_strg(1)+" "+f31_strg(2)+"]";
+        if a.figure_size <> [] then x=x+f31+f31_strg+", "; end
+        f32_strg=String(a.axes_size);
+        f32_strg="["+f32_strg(1)+" "+f32_strg(2)+"]";
+        if a.axes_size <> [] then x=x+f32+f32_strg+", "; end
+        if a.auto_resize<>"on" then x=x+f33+"''"+a.auto_resize+"''"+", "; end
+        f34_strg=String(a.viewport);
+        f34_strg="["+f34_strg(1)+" "+f34_strg(2)+"]";
+        if a.viewport <>[0 0] then x=x+f34+f34_strg+", "; end
+        if a.figure_name<>"Figure n°%d" then x=x+f35+"''"+a.figure_name+"''"+", ";
+        end
+        f36_strg=String(a.figure_id);
+        x=x+f36+f36_strg+", ";
+        if a.info_message<>"" then x=x+f37+"''"+a.info_message+"''"+", "; end
+        if a.pixel_drawing_mode <> "copy" then x=x+f40+"''"+a.pixel_drawing_mode+"''"+", "; end
+        if a.anti_aliasing <> "off" then x=x+f41+"''"+a.anti_aliasing+"''"+", "; end
+        if a.immediate_drawing <>"on" then x=x+f42+"''"+a.immediate_drawing+"''"+", "; end
+        f43_strg=String(f43);
+        if a.background <> 33 then x=x+f43+f43_strg+", "; end
+        if a.visible <> "on" then x=x+f24+"''"+a.visible+"''"+", "; end
+        if a.rotation_style <> "unary" then x=x+f44+"''"+a.rotation_style+"''"+", "; end
+        if a.event_handler <> "" then x=x+f45+"''"+a.event_handler+"''"+", "; end
+        if a.event_handler_enable <> "off" then x=x+f46+"''"+a.event_handler_enable+"''"+", "; end
+        if a.userdata <> [] then
+            if type(a.userdata) == 1 then
+                f47_strg=mat2exp(a.userdata,0)
+            elseif type(a.userdata) == 2 then
+                f47_strg=pol2exp(a.userdata,0)
+            elseif type(a.userdata) == 4 then
+                f47_strg=log2exp(a.userdata,0)
+            elseif type(a.userdata) == 5 | type(a.userdata) == 6 | type(a.userdata) == 7 then
+                f47_strg=sp2exp(a.userdata,0)
+            elseif type(a.userdata) == 8 then
+                f47_strg=int2exp(a.userdata,0)
+            elseif type(a.userdata) == 9 then
+                f47_strg=h2exp(a.userdata,0)
+            elseif type(a.userdata) == 10 then
+                f47_strg=str2exp(a.userdata,0)
+            elseif type(a.userdata) == 11 then
+                f47_strg=func2exp(a.userdata,0)
+                named=%f
+            elseif type(a.userdata) == 13 then
+                if named then
+                    t=fun2string(a,nom)
+                else
+                    t=fun2string(a,"%fun")
+                end
+                t(1)=part(t(1),10:length(t(1)))
+                t($)=[]
+                t=sci2exp(t,lmax)
+                t(1)="createfun("+t(1)
+                t($)=t($)+")"
+            elseif type(a.userdata) == 15 then
+                f47_strg=list2exp(a.userdata);
+            elseif type(a.userdata) == 16 then
+                f47_strg=tlist2exp(a.userdata,0)
+            elseif type(a.userdata) == 17 then
+                f47_strg=mlist2exp(a.userdata,0)
+            elseif type(a.userdata) == 129 then
+                f47_strg=imp2exp(a.userdata,0)
+            end
+            x=x+f28+f47_strg+", ";
+        end
+        if a.resizefcn <> "" then x=x+f47+"''"+a.resizefcn+"''"+", "; end
+        if a.closerequestfcn <> "" then x=x+f48+"''"+a.closerequestfcn+"''"+", "; end
+        if a.tag <> "" then x=x+f27+"''"+a.tag+"''"+", "; end
+        lx=length(x);
+        x=part(x,1:lx-2);
+        t(1)=f+"("+x;
+        t(1)=t(1)+")";
+        dots="."+".";
+        lt=length(t(1))
+        if lt>lmax & lmax<>0 then
+            ind=strindex(x,",");
+            k1=1;l=0;I=[];
+            while %t
+                if lt-l<lmax|k1>length(ind) then break,end
+                k2=k1-1+max(find(ind(k1:$)<l+lmax))
+                I=[I ind(k2)];
+                k1=k2+1
+                l=ind(k2)
+            end
+            t=strsplit(t(1),I);
+            t(1:$-1)=t(1:$-1)+dots;
+        end
+    else
+        error(msprintf(gettext("%s: This feature has not been implemented: Variable translation of type %s.\n"),"sci2exp",string(a.type)));
+    end
+
+endfunction
diff --git a/modules/string/macros/strcmpi.bin b/modules/string/macros/strcmpi.bin
new file mode 100755
index 000000000..1510cbbb5
Binary files /dev/null and b/modules/string/macros/strcmpi.bin differ
diff --git a/modules/string/macros/strcmpi.sci b/modules/string/macros/strcmpi.sci
new file mode 100755
index 000000000..a9fc09758
--- /dev/null
+++ b/modules/string/macros/strcmpi.sci
@@ -0,0 +1,17 @@
+//===============================
+// strcmpi function
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Allan CORNET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+//===============================
+function res = strcmpi(str_one,str_two)
+    res = strcmp(str_one,str_two,"i");
+endfunction
+//===============================
diff --git a/modules/string/macros/tokenpos.bin b/modules/string/macros/tokenpos.bin
new file mode 100755
index 000000000..e4dc288a5
Binary files /dev/null and b/modules/string/macros/tokenpos.bin differ
diff --git a/modules/string/macros/tokenpos.sci b/modules/string/macros/tokenpos.sci
new file mode 100755
index 000000000..1547ca8ea
--- /dev/null
+++ b/modules/string/macros/tokenpos.sci
@@ -0,0 +1,29 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function kdf=tokenpos(str,sep)
+    //return a vector of indices giving the beginning of the included
+    //tokens
+    if argn(2)<2 then sep=[" ",ascii(9)],end
+
+    if size(str,"*")<> 1 then
+        error(msprintf(gettext("%s: Wrong size for input argument #%d: A character string expected.\n"),"tokenpos",1));
+    end
+    if or(length(sep)<>1) then
+        error(msprintf(gettext("%s: Wrong size for input argument #%d: A character or vector of characters expected.\n"),"tokenpos",2));
+    end
+    str=sep(1)+str+sep(1)
+    k1=strindex(str,sep)
+    i=find(k1(2:$)-k1(1:$-1)>1)
+    if i<>[] then
+        kdf=[k1(i);k1(i+1)-2]'
+    else
+        kdf=[]
+    end
+endfunction
diff --git a/modules/string/macros/tree2code.bin b/modules/string/macros/tree2code.bin
new file mode 100755
index 000000000..b1f3c6df9
Binary files /dev/null and b/modules/string/macros/tree2code.bin differ
diff --git a/modules/string/macros/tree2code.sci b/modules/string/macros/tree2code.sci
new file mode 100755
index 000000000..776924c20
--- /dev/null
+++ b/modules/string/macros/tree2code.sci
@@ -0,0 +1,71 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA - Vincent Couvert
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+
+function C=tree2code(P,bprettyprintformat)
+    // Convert a tree returned by macr2tree() to a macro code
+    // Input:
+    // - P: 'program' tlist
+    // - bprettyprintformat: boolean value, if FALSE (default value), generated code is not formated else it is
+    // Output:
+    // - C: character string matrix (colum vector)
+
+    // Verify good type for input
+    if typeof(P)<>"program" then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: ''%s'' expected.\n"),"tree2code",2,"program tree"));
+    end
+
+    // Default value
+    rhs = argn(2);
+    if rhs==1 then
+        bprettyprintformat=%F
+    end
+
+    C=""
+
+    // Function prototype
+    lhsstr=[]
+    rhsstr=[]
+    if P.name<>"" then // Not a batch file
+        for k=1:size(P.outputs)
+            lhsstr=[lhsstr,expression2code(P.outputs(k))]
+        end
+        lhsstr="["+strcat(lhsstr,",")+"]"
+
+        for k=1:size(P.inputs)
+            rhsstr=[rhsstr,expression2code(P.inputs(k))]
+        end
+        rhsstr="("+strcat(rhsstr,",")+")"
+
+        C="function "+lhsstr+" = "+P.name+rhsstr;
+    end
+
+    I=P.statements
+
+    // To avoid to have some instructions on the first line (function prototype)
+    if I(1)<>list("EOL") then
+        C=cat_code(C,instruction2code(list("EOL"),%T));
+    end
+
+    // For each statement, generate corresponding code
+    for i=1:size(I)-2 // -2 to ignore last return+EOL
+        if bprettyprintformat then
+            C=cat_code(C,"  "+instruction2code(I(i),bprettyprintformat));
+        else
+            C=cat_code(C,instruction2code(I(i),bprettyprintformat));
+        end
+        C = format_txt(C,I(i),bprettyprintformat,I(i+1));
+    end
+
+    if P.name<>"" then // Not a batch file
+        C=cat_code(C,"endfunction"); // Replace last return
+        C=cat_code(C,"");
+    end
+endfunction
+
-- 
cgit