Remove obsolete check_mac (inner function) 41/16241/3
Paul Bignier [Wed, 25 Mar 2015 13:21:43 +0000 (14:21 +0100)]
 * deff() now identifies syntax errors, so testing them with check_mac isn't needed anymore
 * Used by EXPRESSION block:
  --> loadXcosLibs();
  --> exec("SCI/test/xcos/EXPRESSION_en_US.cosf", -1);
  --> cpr=scicos_simulate(scs_m);

Change-Id: I55c943497d370c26c79e68581bd853ef5fdb246b

scilab/modules/scicos/macros/scicos_scicos/check_mac.sci [deleted file]
scilab/modules/scicos/macros/scicos_scicos/genfunc1.sci
scilab/modules/scicos/macros/scicos_scicos/genfunc2.sci

diff --git a/scilab/modules/scicos/macros/scicos_scicos/check_mac.sci b/scilab/modules/scicos/macros/scicos_scicos/check_mac.sci
deleted file mode 100644 (file)
index fb47f64..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-//  Scicos
-//
-//  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// See the file ../license.txt
-//
-
-function ok=check_mac(txt)
-    //errcatch doesnt work poperly
-    ok=%t
-    if execstr("comp(mac)","errcatch")<>0 then
-        messagebox(["Incorrect syntax: ";lasterror()],"modal")
-        ok=%f
-    end
-endfunction
index 1b888b3..6a8e952 100644 (file)
@@ -60,9 +60,10 @@ function [ok,tt,dep_ut]=genfunc1(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "as a functions of "+depp],txt1)
             if txt1==[] then return,end
             // check if txt defines y from u
-            mac=null();deff("[]=mac()",txt1,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt1,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 for k=1:ni
                     if or(vars(3)=="u"+string(k)) then dep_u=%t,end
@@ -96,9 +97,10 @@ function [ok,tt,dep_ut]=genfunc1(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "as  function(s) of "+depp],txt0)
 
             if txt0==[] then return,end
-            mac=null();deff("[]=mac()",txt0,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt0,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 if or(vars(5)=="xd") then
                     break,
@@ -126,9 +128,10 @@ function [ok,tt,dep_ut]=genfunc1(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             t1
             "at event time, as functions of "+depp],txt2)
             if txt2==[] then return,end
-            mac=null();deff("[]=mac()",txt2,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt2,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 if ~or(vars(5)=="x") then txt3=[txt3;"x=[]"];end
                 if ~or(vars(5)=="z") then txt3=[txt3;"z=[]"];end
@@ -149,10 +152,10 @@ function [ok,tt,dep_ut]=genfunc1(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "vector of output time events t_evo (size:"+string(nco)+")"
             "at event time. "],txt3)
             if txt3==[] then return,end
-            mac=null();deff("[]=mac()",txt3,"n")
-            //   alan.layec
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt3,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 if ~or(vars(5)=="t_evo") then txt3=[txt3;"t_evo=[]"];end
                 break;
@@ -182,9 +185,12 @@ function [ok,tt,dep_ut]=genfunc1(tt,inp,out,nci,nco,nx,nz,nrp,type_)
         t1
         "as  function(s) of "+depp],txt4)
         if txt4==[] then return,end
-        mac=null();deff("[]=mac()",txt4,"n")
-        ok1=check_mac(mac)
-        if ok1 then break,end
+        mac=null();
+        if execstr("deff(""[]=mac()"",txt4,""n"")", "errcatch") <> 0 then
+            messagebox(["Incorrect syntax: ";lasterror()],"modal")
+        else
+            break
+        end
     end
 
     //flag = 5
@@ -206,9 +212,12 @@ function [ok,tt,dep_ut]=genfunc1(tt,inp,out,nci,nco,nx,nz,nrp,type_)
         t1
         "as  function(s) of "+depp],txt5)
         if txt5==[] then return,end
-        mac=null();deff("[]=mac()",txt5,"n")
-        ok1=check_mac(mac)
-        if ok1 then break,end
+        mac=null();
+        if execstr("deff(""[]=mac()"",txt5,""n"")", "errcatch") <> 0 then
+            messagebox(["Incorrect syntax: ";lasterror()],"modal")
+        else
+            break
+        end
     end
 
     //flag = 6
@@ -238,9 +247,10 @@ function [ok,tt,dep_ut]=genfunc1(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "as a function of "+depp],txt6)
             if txt6==[] then return,end
 
-            mac=null();deff("[]=mac()",txt6,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt6,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 for k=1:no
                     if and(vars(5)<>"y"+string(k)) then txt6=[txt6;"y"+string(k)+"=[]"],end
index 9bd66fd..78cc283 100644 (file)
@@ -60,9 +60,10 @@ function [ok,tt,dep_ut]=genfunc2(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "as a functions of "+depp],txt1)
             if txt1==[] then return,end
             // check if txt defines y from u
-            mac=null();deff("[]=mac()",txt1,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt1,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 for k=1:ni
                     if or(vars(3)=="u"+string(k)) then dep_u=%t,end
@@ -96,9 +97,10 @@ function [ok,tt,dep_ut]=genfunc2(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "as  function(s) of "+depp],txt0)
 
             if txt0==[] then return,end
-            mac=null();deff("[]=mac()",txt0,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt0,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 if or(vars(5)=="xd") then
                     break,
@@ -126,9 +128,10 @@ function [ok,tt,dep_ut]=genfunc2(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             t1
             "at event time, as functions of "+depp],txt2)
             if txt2==[] then return,end
-            mac=null();deff("[]=mac()",txt2,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt2,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 if ~or(vars(5)=="x") then txt3=[txt3;"x=[]"];end
                 if ~or(vars(5)=="z") then txt3=[txt3;"z=[]"];end
@@ -149,9 +152,10 @@ function [ok,tt,dep_ut]=genfunc2(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "vector of output time events t_evo (size:"+string(nco)+")"
             "at event time. "],txt3)
             if txt3==[] then return,end
-            mac=null();deff("[]=mac()",txt3,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt3,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 if ~or(vars(5)=="t_evo") then txt3=[txt3;"t_evo=[]"];end
                 break;
@@ -181,9 +185,12 @@ function [ok,tt,dep_ut]=genfunc2(tt,inp,out,nci,nco,nx,nz,nrp,type_)
         t1
         "as  function(s) of "+depp],txt4)
         if txt4==[] then return,end
-        mac=null();deff("[]=mac()",txt4,"n")
-        ok1=check_mac(mac)
-        if ok1 then break,end
+        mac=null();
+        if execstr("deff(""[]=mac()"",txt4,""n"")", "errcatch") <> 0 then
+            messagebox(["Incorrect syntax: ";lasterror()],"modal")
+        else
+            break
+        end
     end
 
     //flag = 5
@@ -205,9 +212,12 @@ function [ok,tt,dep_ut]=genfunc2(tt,inp,out,nci,nco,nx,nz,nrp,type_)
         t1
         "as  function(s) of "+depp],txt5)
         if txt5==[] then return,end
-        mac=null();deff("[]=mac()",txt5,"n")
-        ok1=check_mac(mac)
-        if ok1 then break,end
+        mac=null();
+        if execstr("deff(""[]=mac()"",txt5,""n"")", "errcatch") <> 0 then
+            messagebox(["Incorrect syntax: ";lasterror()],"modal")
+        else
+            break
+        end
     end
 
     //flag = 6
@@ -238,9 +248,10 @@ function [ok,tt,dep_ut]=genfunc2(tt,inp,out,nci,nco,nx,nz,nrp,type_)
             "as a function of "+depp],txt6)
             if txt6==[] then return,end
 
-            mac=null();deff("[]=mac()",txt6,"n")
-            ok1=check_mac(mac)
-            if ok1 then
+            mac=null();
+            if execstr("deff(""[]=mac()"",txt6,""n"")", "errcatch") <> 0 then
+                messagebox(["Incorrect syntax: ";lasterror()],"modal")
+            else
                 vars=macrovar(mac)
                 for k=1:no
                     if and(vars(5)<>"y"+string(k)) then txt6=[txt6;"y"+string(k)+"=[]"],end