cosmetics + more error messages
Laurent VAYLET [Tue, 29 Apr 2008 15:52:21 +0000 (15:52 +0000)]
scilab/modules/scicos/macros/scicos_auto/scicos_simulate.sci
scilab/modules/scicos/macros/scicos_scicos/do_eval.sci

index ef41bea..03ffac0 100644 (file)
 // See the file ./license.txt
 //
 
-function Info=scicos_simulate(scs_m,Info,%scicos_context,flag,Ignb)
+function Info = scicos_simulate(scs_m, Info, %scicos_context, flag, Ignb)
 // Function for running scicos simulation in batch mode
-// Info=scicos_simulate(scs_m[,Info][,%scicos_context][,flag]...
-//                      [,Ignb])
+// Info = scicos_simulate(scs_m[,Info][,%scicos_context][,flag][,Ignb])
 //
 // scs_m: scicos diagram (obtained by "load file.cos"). Note that
 // the version of file.cos must be the current version. If not, load
@@ -55,13 +54,13 @@ function Info=scicos_simulate(scs_m,Info,%scicos_context,flag,Ignb)
 // of blocks to ignore.
 //
 
-  noguimode=find(sciargs()=="-nogui");
-  if (noguimode <>[]) then
+  noguimode = find(sciargs() == "-nogui");
+  if (noguimode <> []) then
      clear noguimode
-     flag='nw'
+     flag = 'nw'
   //    warning(" Scilab in no gui mode : Scicos unavailable");
   //    abort;
-  end;
+  end
   clear noguimode
 
   //** define Scicos data tables
@@ -70,11 +69,11 @@ function Info=scicos_simulate(scs_m,Info,%scicos_context,flag,Ignb)
       ~isdef("%scicos_display_mode") | ~isdef("modelica_libs") | ..
       ~isdef("scicos_pal_libs") | ~isdef("%scicos_gif") | ..
       ~isdef("%scicos_contrib") ) then
-         [scicos_pal,%scicos_menu,...
-          %scicos_short,%scicos_help,..
-          %scicos_display_mode,modelica_libs,..
-          scicos_pal_libs,%scicos_gif,..
-          %scicos_contrib]=initial_scicos_tables()
+         [scicos_pal, %scicos_menu,...
+          %scicos_short, %scicos_help,..
+          %scicos_display_mode, modelica_libs,..
+          scicos_pal_libs, %scicos_gif,..
+          %scicos_contrib] = initial_scicos_tables()
          clear initial_scicos_tables
   end
 
@@ -82,19 +81,19 @@ function Info=scicos_simulate(scs_m,Info,%scicos_context,flag,Ignb)
   %scicos_debug_gr = %f;
 
   //** list of scopes to ignore
-  Ignoreb=['bouncexy',...
-           'cscope',...
-           'cmscope',...
-           'canimxy',...
-           'canimxy3d',...
-           'cevscpe',...
-           'cfscope',...
-           'cscopxy',...
-           'cscopxy3d',...
-           'cmatview',...
-           'cmat3d',...
-           'affich',...
-           'affich2']
+  Ignoreb = ['bouncexy', ...
+             'cscope', ...
+                                                'cmscope', ...
+                                                'canimxy', ...
+                                                'canimxy3d', ...
+                                                'cevscpe', ...
+                                                'cfscope', ...
+                                                'cscopxy', ...
+                                                'cscopxy3d', ...
+                                                'cmatview', ...
+                                                'cmat3d', ...
+                                                'affich', ...
+                                                'affich2']
 
   //** load macros libraries and palettes
   // Scilab 5 new modules split
@@ -105,76 +104,81 @@ function Info=scicos_simulate(scs_m,Info,%scicos_context,flag,Ignb)
   exec(loadpallibs,-1)
 
   //** redefine some gui functions
-  prot=funcprot();funcprot(0);
+  prot = funcprot();funcprot(0);
   deff('disablemenus()',' ')
   deff('enablemenus()',' ')
-  do_terminate=do_terminate1
+  do_terminate = do_terminate1
   funcprot(prot)
 
   //** check/set rhs parameters
-  if argn(2)==1 then
-    Info=list()
-    %scicos_context=struct()
-    flag=[]
-    Ignb=[]
-  elseif argn(2)==2 then
-    if type(Info)==10&(stripblanks(Info)=='nw') then
-      Info=list()
-      flag='nw'
-    elseif type(Info)<>15 then
-      Info=list()
-      flag=[]
+  if argn(2) == 1 then
+    Info            = list()
+    %scicos_context = struct()
+    flag            = []
+    Ignb            = []
+
+       elseif argn(2) == 2 then
+    if type(Info) == 10 & (stripblanks(Info) == 'nw') then
+      Info = list()
+      flag = 'nw'
+    elseif type(Info) <> 15 then
+      Info = list()
+      flag = []
     else
-      flag=[]
+      flag = []
     end
-    %scicos_context=struct()
-    Ignb=[]
-  elseif argn(2)==3 then
-    if type(Info)<>15 then
-      Info=list()
+    %scicos_context = struct()
+    Ignb = []
+
+       elseif argn(2) == 3 then
+    if type(Info) <> 15 then
+      Info = list()
     end
-    if type(%scicos_context)==10&(stripblanks(%scicos_context)=='nw') then
-      %scicos_context=struct()
-      flag='nw'
-    elseif type(%scicos_context)<>17 then
-      %scicos_context=struct()
-      flag=[]
+    if type(%scicos_context) == 10 & (stripblanks(%scicos_context) == 'nw') then
+      %scicos_context = struct()
+      flag = 'nw'
+    elseif type(%scicos_context) <> 17 then
+      %scicos_context = struct()
+      flag = []
     else
-      flag=[]
+      flag = []
     end
-    Ignb=[]
-  elseif argn(2)==4 then
-    if type(Info)<>15 then
-      Info=list()
+    Ignb = []
+
+       elseif argn(2) == 4 then
+    if type(Info) <> 15 then
+      Info = list()
     end
-    if type(%scicos_context)<>17 then
-      %scicos_context=struct()
+    if type(%scicos_context) <> 17 then
+      %scicos_context = struct()
     end
-    if type(flag)<>10 then
-     flag=[]
-    elseif (stripblanks(flag)<>'nw') then
-       flag=[]
+    if type(flag) <> 10 then
+     flag = []
+    elseif (stripblanks(flag) <> 'nw') then
+       flag = []
     end
-    Ignb=[]
-  elseif argn(2)==5 then
-    if type(Info)<>15 then
-      Info=list()
+    Ignb = []
+
+       elseif argn(2) == 5 then
+    if type(Info) <> 15 then
+      Info = list()
     end
-    if type(%scicos_context)<>17 then
-      %scicos_context=struct()
+    if type(%scicos_context) <> 17 then
+      %scicos_context = struct()
     end
-    if type(flag)<>10 then
-      flag=[]
-    elseif (stripblanks(flag)<>'nw') then
-      flag=[]
+    if type(flag) <> 10 then
+      flag = []
+    elseif (stripblanks(flag) <> 'nw') then
+      flag = []
     end
-    if type(Ignb)<>10 then
-      Ignb=[]
+    if type(Ignb) <> 10 then
+      Ignb = []
     else
-      Ignb=(Ignb(:))'
+      Ignb = (Ignb(:))'
     end
-  else
-     error('scicos_simulate : wrong number of parameters.')
+
+       else
+     error(mprintf(gettext("%s: Wrong number of input arguments. Must be between %d and %d.\n"), "scicos_simulate", 1, 5))
   end
 
   //check version
@@ -182,166 +186,184 @@ function Info=scicos_simulate(scs_m,Info,%scicos_context,flag,Ignb)
   scicos_ver = find_scicos_version(scs_m)
 
   //do version
-  if scicos_ver<>current_version then
-    ierr=execstr('scs_m=do_version(scs_m,scicos_ver)','errcatch')
-    if ierr<>0 then
+  if scicos_ver <> current_version then
+    ierr = execstr('scs_m = do_version(scs_m, scicos_ver)','errcatch')
+    if ierr <> 0 then
       message("Can''t convert old diagram (problem in version)")
       return
     end
   end
 
   //prepare from and to workspace stuff
-  curdir=getcwd()
+  curdir = getcwd()
   chdir(TMPDIR)
   mkdir('Workspace')
   chdir('Workspace')
-  %a=who('get');
-  %a=%a(1:$-predef()+1);  // exclude protected variables
-  for %ij=1:size(%a,1)
-    var=%a(%ij)
-    if var<>'ans' & typeof(evstr(var))=='st' then
-      ierr=execstr('x='+var+'.values','errcatch')
-      if ierr==0 then
-        ierr=execstr('t='+var+'.time','errcatch')
+  %a = who('get');
+  %a = %a(1:$-predef()+1);  // exclude protected variables
+  for %ij = 1:size(%a,1)
+    var = %a(%ij)
+    if var <> 'ans' & typeof(evstr(var)) == 'st' then
+      ierr = execstr('x = ' + var + '.values','errcatch')
+      if ierr == 0 then
+        ierr = execstr('t = ' + var + '.time','errcatch')
       end
-      if ierr==0 then
-        execstr('save('"'+var+''",x,t)')
+      if ierr == 0 then
+        execstr('save('"' + var + ''",x,t)')
       end
     end
   end
   chdir(curdir)
   // end of /prepare from and to workspace stuff
 
-  Ignore=[]
+  Ignore = []
 
-  if flag=='nw' then
-    Ignore=Ignoreb
+  if flag == 'nw' then
+    Ignore = Ignoreb
   end
 
-  if Ignb<>[] then
-    Ignore=[Ignore,Ignb]
+  if Ignb <> [] then
+    Ignore = [Ignore, Ignb]
   end
 
   //** retrieve Info list
-  if Info<>list() then
-    [%tcur,%cpr,alreadyran,needstart,needcompile,%state0]=Info(:)
+  if Info <> list() then
+    [%tcur, %cpr, alreadyran, needstart, needcompile, %state0] = Info(:)
   else
-    %tcur=0;%cpr=list();alreadyran=%f;needstart=%t;needcompile=4;%state0=list();
+    %tcur = 0;
+               %cpr = list();
+               alreadyran = %f;
+               needstart = %t;
+               needcompile = 4;
+               %state0 = list();
   end
 
   //** set solver
-  tolerances=scs_m.props.tol
-  solver=tolerances(6)
-  %scicos_solver=solver
+  tolerances     = scs_m.props.tol
+  solver         = tolerances(6)
+  %scicos_solver = solver
 
   //** set variables of context
-  [%scicos_context,ierr]=script2var(scs_m.props.context, ...
-                                   %scicos_context);
+  [%scicos_context, ierr] = script2var(scs_m.props.context, ...
+               %scicos_context);
+
+  if ierr == 0 then //++ no error
 
-  if ierr==0 then
-    [scs_m,%cpr,needcompile,ok]=do_eval(scs_m,%cpr)
-    if needcompile<>4&size(%cpr)>0 then %state0=%cpr.state,end
-    alreadyran=%f
+    [scs_m, %cpr, needcompile, ok] = do_eval(scs_m, %cpr)
+
+    if needcompile <> 4 & size(%cpr) > 0 then
+                       %state0 = %cpr.state
+               end
+    alreadyran = %f
   else
-      error(['Incorrect context definition, '+lasterror()] )
+    error(['Incorrect context definition, ' + lasterror()])
   end
 
-  if %cpr==list() then need_suppress=%t, else need_suppress=%f,end
+  if %cpr == list() then
+               need_suppress  =%t
+       else
+               need_suppress = %f
+       end
 
-  [%cpr,%state0_n,needcompile,alreadyran,ok]=..
-      do_update(%cpr,%state0,needcompile)
-  if ~ok then error('Error updating parameters.'),end
+  [%cpr, %state0_n, needcompile, alreadyran, ok] = do_update(%cpr, ...
+               %state0, needcompile)
+  if ~ok then
+               error('Error updating parameters.')
+       end
 
-  if or(%state0_n<>%state0) then //initial state has been changed
-    %state0=%state0_n
-    [alreadyran,%cpr]=do_terminate1(scs_m,%cpr)
-    choix=[]
+  if or(%state0_n <> %state0) then //initial state has been changed
+    %state0 = %state0_n
+    [alreadyran, %cpr] = do_terminate1(scs_m, %cpr)
+    choix = []
   end
-  if %cpr.sim.xptr($)-1<size(%cpr.state.x,'*') & solver<100 then
+  if (%cpr.sim.xptr($) - 1) < size(%cpr.state.x,'*') & solver < 100 then
     warning(['Diagram has been compiled for implicit solver'
-            'switching to implicit Solver'])
-    solver=100
-    tolerances(6)=solver
-  elseif (%cpr.sim.xptr($)-1==size(%cpr.state.x,'*')) & ..
-       ( solver==100 & size(%cpr.state.x,'*')<>0) then
+            'switching to implicit solver'])
+    solver = 100
+    tolerances(6) = solver
+  elseif (%cpr.sim.xptr($) - 1) == size(%cpr.state.x,'*') & ...
+               solver == 100 & size(%cpr.state.x,'*') <> 0 then
     warning(['Diagram has been compiled for explicit solver'
-            'switching to explicit Solver'])
-    solver=0
-    tolerances(6)=solver
+            'switching to explicit solver'])
+    solver = 0
+    tolerances(6) = solver
   end
 
   if need_suppress then //this is done only once
-    for i=1:length(%cpr.sim.funs)
-      if type(%cpr.sim.funs(i))<>13 then
-       if find(%cpr.sim.funs(i)(1)==Ignore)<>[] then
-         %cpr.sim.funs(i)(1)='trash';
-       end
+    for i = 1:length(%cpr.sim.funs)
+      if type(%cpr.sim.funs(i)) <> 13 then
+                               if find(%cpr.sim.funs(i)(1) == Ignore) <> [] then
+                                       %cpr.sim.funs(i)(1) = 'trash';
+                               end
       end
     end
   end
 
   if needstart then //scicos initialisation
     if alreadyran then
-      [alreadyran,%cpr]=do_terminate1(scs_m,%cpr)
-      alreadyran=%f
+      [alreadyran, %cpr] = do_terminate1(scs_m, %cpr)
+      alreadyran = %f
     end
-    %tcur=0
-    %cpr.state=%state0
-    tf=scs_m.props.tf;
-    if tf*tolerances==[] then
+    %tcur = 0
+    %cpr.state = %state0
+    tf = scs_m.props.tf;
+    if tf*tolerances == [] then
       error(['Simulation parameters not set']);
     end
 
-    ierr=execstr('[state,t]=scicosim(%cpr.state,%tcur,tf,%cpr.sim,'+..
-                '''start'',tolerances)','errcatch')
-    if ierr<>0 then
+    ierr = execstr('[state, t] = scicosim(%cpr.state, %tcur, tf, %cpr.sim,' + ..
+                '''start'', tolerances)','errcatch')
+    if ierr <> 0 then
       error(['Initialisation problem:'])
     end
-    %cpr.state=state
+    %cpr.state = state
   end
 
-  ierr=execstr('[state,t]=scicosim(%cpr.state,%tcur,tf,%cpr.sim,'+..
-              '''run'',tolerances)','errcatch')
+  ierr = execstr('[state, t] = scicosim(%cpr.state, %tcur, tf, %cpr.sim,' + ..
+               '''run'', tolerances)','errcatch')
 
-  if ierr==0 then
-    %cpr.state=state
-    alreadyran=%t
-    if tf-t<tolerances(3) then
-      needstart=%t
-      [alreadyran,%cpr]=do_terminate1(scs_m,%cpr)
+  if ierr == 0 then
+    %cpr.state = state
+    alreadyran = %t
+    if (tf - t) < tolerances(3) then
+      needstart = %t
+      [alreadyran, %cpr] = do_terminate1(scs_m, %cpr)
     else
-      %tcur=t
+      %tcur = t
     end
   else
-    error(['Simulation problem:';lasterror()])
+    error(['Simulation problem: ';lasterror()])
   end
 
-  Info=list(%tcur,%cpr,alreadyran,needstart,needcompile,%state0)
+  Info = list(%tcur, %cpr, alreadyran, needstart, needcompile, %state0)
 
-  [txt,files]=returntoscilab()
-  n=size(files,1)
-  for i=1:n
-    load(TMPDIR+'/Workspace/'+files(i))
-    execstr(files(i)+'=struct('"values'",x,'"time'",t)')
+  [txt, files] = returntoscilab()
+  n = size(files,1)
+  for i = 1:n
+    load(TMPDIR + '/Workspace/' + files(i))
+    execstr(files(i) + ' = struct('"values'", x, '"time'", t)')
   end
   execstr(txt)
 endfunction
 
-function [alreadyran,%cpr]=do_terminate1(scs_m,%cpr)
+function [alreadyran, %cpr] = do_terminate1(scs_m, %cpr)
 // Copyright INRIA
 
-  if prod(size(%cpr))<2 then   alreadyran=%f,return,end
-  par=scs_m.props;
+  if prod(size(%cpr)) < 2 then
+               alreadyran = %f
+               return
+       end
+
+       par = scs_m.props;
 
   if alreadyran then
-    alreadyran=%f
-    //terminate current simulation
-    ierr=execstr('[state,t]=scicosim(%cpr.state,par.tf,par.tf,'+..
-                '%cpr.sim,''finish'',par.tol)','errcatch')
-
-    %cpr.state=state
-    if ierr<>0 then
-      error(['End problem:';lasterror()])
+    alreadyran = %f
+    // terminate current simulation
+    ierr = execstr('[state, t] = scicosim(%cpr.state, par.tf, par.tf, %cpr.sim, ''finish'', par.tol)', 'errcatch')
+
+    %cpr.state = state
+    if ierr <> 0 then
+      error(['End problem: ' ; lasterror()])
     end
   end
 endfunction
index 6400633..2749ed5 100644 (file)
 // See the file ../license.txt
 //
 
-function [scs_m,cpr,needcompile,ok]=do_eval(scs_m,cpr)
-// This function (re)-evaluates blocks in the scicos data structure scs_m 
-ok=%t
-needcompile1=max(2,needcompile)
-%mprt=funcprot()
-funcprot(0) 
-getvalue=setvalue;
+function [scs_m, cpr, needcompile, ok] = do_eval(scs_m, cpr)
+       // This function (re)-evaluates blocks in the scicos data structure scs_m
 
-deff('message(txt)','x_message(''In block ''+o.gui+'': ''+txt);%scicos_prob=resume(%t)')
+       ok = %t
+       needcompile1 = max(2,needcompile)
+       %mprt = funcprot()
+       funcprot(0)
+       getvalue = setvalue;
 
-%scicos_prob=%f
-deff('[ok,tt]=FORTR(funam,tt,i,o)','ok=%t')
-deff('[ok,tt]=CFORTR2(funam,tt,i,o)','ok=%t')
-deff('[ok,tt]=CFORTR(funam,tt,i,o)','ok=%t')
-deff('[x,y,ok,gc]=edit_curv(x,y,job,tit,gc)','ok=%t')
-deff('[ok,tt,dep_ut]=genfunc1(tt,ni,no,nci,nco,nx,nz,nrp,type_)',..
-    'dep_ut=model.dep_ut;ok=%t')
-deff('result=dialog(labels,valueini)','result=valueini')
-%nx=lstsize(scs_m.objs)
-deff('[ok,tt]=MODCOM(funam,tt,vinp,vout,vparam,vparamv,vpprop)',..
-   '[dirF,nameF,extF]=fileparts(funam);..
-    tarpath=pathconvert(TMPDIR+''/Modelica/'',%f,%t);..
-    if (extF=='''')  then,..
-        funam1=tarpath+nameF+''.mo'';..
-    elseif fileinfo(funam)==[] then,..
-        funam1=funam;..
-    end;..
-    mputl(tt,funam1);..
-    compilerpath=pathconvert(SCI+''/bin/'',%f,%t);..
-    if MSDOS then,..
-       compilerpath=compilerpath+''modelicac.exe'';..
-    else,.. 
-        compilerpath=compilerpath+''modelicac'';..
-    end;..
-    ..
-    if execstr(''unix_s(compilerpath+'''' -c ''''+funam1+'''' -o ''''+tarpath+nameF+''''.moc'''')'',''errcatch'')<>0 then,..
-       ok=%f;..
-    else,..
-        ok=%t;..
-      end;')
-funcprot(%mprt)
-for %kk=1:%nx
-  o=scs_m.objs(%kk)
-  if typeof(o)=='Block' then
-    model=o.model
-    if model.sim=='super'| (model.sim=='csuper'&model.ipar<>1) then  //exclude mask
-      sblock=model.rpar
-      context=sblock.props.context
+       deff('message(txt)','x_message(''In block '' + o.gui + '': '' + txt); %scicos_prob = resume(%t)')
 
-      [%scicos_context,ierr]=script2var(context,%scicos_context)
+       %scicos_prob = %f
+       deff('[ok, tt] = FORTR(funam, tt, i, o)','ok = %t')
+       deff('[ok, tt] = CFORTR2(funam, tt, i, o)','ok = %t')
+       deff('[ok, tt] = CFORTR(funam, tt, i, o)','ok = %t')
+       deff('[x, y, ok, gc] = edit_curv(x, y, job, tit, gc)','ok = %t')
+       deff('[ok,tt,dep_ut] = genfunc1(tt, ni, no, nci, nco, nx, nz, nrp, type_)',..
+                       'dep_ut = model.dep_ut; ok = %t')
+       deff('result = dialog(labels, valueini)','result = valueini')
+       %nx = lstsize(scs_m.objs)
+       deff('[ok, tt] = MODCOM(funam, tt, vinp, vout, vparam, vparamv, vpprop)',..
+                '[dirF, nameF, extF]=fileparts(funam);..
+                       tarpath = pathconvert(TMPDIR + ''/Modelica/'', %f, %t);..
+                       if (extF == '''')  then,..
+                                       funam1 = tarpath + nameF + ''.mo'';..
+                       elseif fileinfo(funam) == [] then,..
+                                       funam1 = funam;..
+                       end;..
+                       mputl(tt, funam1);..
+                       compilerpath = pathconvert(SCI + ''/bin/'', %f, %t);..
+                       if MSDOS then,..
+                               compilerpath = compilerpath + ''modelicac.exe'';..
+                       else,..
+                               compilerpath = compilerpath + ''modelicac'';..
+                       end;..
+                       ..
+                       if execstr(''unix_s(compilerpath + '''' -c '''' + funam1 + '''' -o '''' + tarpath + nameF + ''''.moc'''')'',''errcatch'') <> 0 then,..
+                               ok = %f;..
+                       else,..
+                               ok=%t;..
+                       end;')
+       funcprot(%mprt)
 
-      if ierr <>0 then
-       %now_win=xget('window')
-        message(['Cannot evaluate a context';lasterror()])
-       xset('window',%now_win)
-      else
-        [sblock,%w,needcompile2,ok]=do_eval(sblock,list())
-        needcompile1=max(needcompile1,needcompile2)
-        if ok then
-          scs_m.objs(%kk).model.rpar=sblock
-        end
-      end
-    else
-      model=o.model
-// should we generate a message here?
-      ier=execstr('o='+o.gui+'(''set'',o)','errcatch')
-      if ier==0 then
-        needcompile1=max(needcompile1,needcompile) // for scifunc_block
-        model_n=o.model
-        if or(model.blocktype<>model_n.blocktype)|.. // type 'c','d','z','l'
-            or(model.dep_ut<>model_n.dep_ut)|..
-              (model.nzcross<>model_n.nzcross)|..
-              (model.nmode<>model_n.nmode) then
-         needcompile1=4
-        end
-        if (size(model.in,'*')<>size(model_n.in,'*'))|..
-           (size(model.out,'*')<>size(model_n.out,'*'))|..
-            (size(model.evtin,'*')<>size(model_n.evtin,'*')) then
-         // number of input (evt or regular ) or output  changed
-         needcompile1=4
-        end
-        if model.sim=='input'|model.sim=='output' then
-          if model.ipar<>model_n.ipar then
-             needcompile1=4
-          end
-        end
-        scs_m.objs(%kk)=o
-      end  // message for else here
-    end
-  end
-end
-needcompile=needcompile1
-if needcompile==4 then cpr=list(),end
+       for %kk = 1:%nx
+               o = scs_m.objs(%kk)
+               if typeof(o) == 'Block' then
+                       model = o.model
+                       if model.sim == 'super' | (model.sim == 'csuper' & model.ipar <> 1) then  //exclude mask
+                               sblock = model.rpar
+                               context = sblock.props.context
+
+                               [%scicos_context, ierr] = script2var(context, %scicos_context)
+
+                               if ierr <> 0 then
+                                       %now_win = xget('window')
+                                       message(['Cannot evaluate a context '; lasterror()])
+                                       xset('window', %now_win)
+                               else
+                                       [sblock, %w, needcompile2, ok] = do_eval(sblock, list())
+                                       needcompile1 = max(needcompile1, needcompile2)
+                                       if ok then
+                                               scs_m.objs(%kk).model.rpar = sblock
+                                       end
+                               end
+                       else
+                               model = o.model
+
+                               // should we generate a message here ?
+                               ier = execstr('o = ' + o.gui + '(''set'',o)', 'errcatch')
+
+                               if ier == 0 then //++ no error
+                                       needcompile1 = max(needcompile1, needcompile) // for scifunc_block
+                                       model_n = o.model
+                                       if or(model.blocktype <> model_n.blocktype) | .. // type 'c','d','z','l'
+                                                or(model.dep_ut <> model_n.dep_ut) | ..
+                                                (model.nzcross <> model_n.nzcross) | ..
+                                                (model.nmode <> model_n.nmode) then
+                                        needcompile1 = 4
+                                       end
+                                       if (size(model.in,'*')    <> size(model_n.in,'*')) | ..
+                                                (size(model.out,'*')   <> size(model_n.out,'*')) | ..
+                                                (size(model.evtin,'*') <> size(model_n.evtin,'*')) then
+                                        // number of input (evt or regular ) or output  changed
+                                        needcompile1 = 4
+                                       end
+                                       if model.sim == 'input' | model.sim == 'output' then
+                                               if model.ipar <> model_n.ipar then
+                                                        needcompile1 = 4
+                                               end
+                                       end
+                                       scs_m.objs(%kk) = o
+                               end // message for else here
+                       end
+               end
+       end
+
+       needcompile = needcompile1
+
+       if needcompile == 4 then
+               cpr = list()
+       end
 endfunction
+