[Scilab-users] ?==?utf-8?q? How to replicate what "load" does (aka creating variable in the current workspace from inside a function)?

Clément David clement.david at scilab-enterprises.com
Mon Feb 22 12:38:36 CET 2016


Hello Antoine, Serge,

Le lundi 22 février 2016 à 12:04 +0100, Antoine Monmayrant a écrit :
>  
> Le Lundi 22 Février 2016 11:51 CET, Serge Steer <Serge.Steer at inria.fr> a écrit: 
>  
> > The following function does the job:
> > 
> > function myload()
> >    txt=["a=1";"b=2"];
> >    ncur= size(who("local"),"*")
> >    execstr(txt);
> >    vars=who("local");
> >    vars=vars(1:size(vars,'*')-ncur-1)
> >    args=strcat(vars,",")
> >    execstr("["+args+"]=resume("+args+")")
> > endfunction
> 
> Thank you Serge!
> It does work on 5.5.0, but it does not work on 6.6.0-beta1.
> It might be due to the way variables are ordered when calling "who".

Not sure if it is related to `who` or to the special use of `resume`.

The resume will push its arguments to the caller context and thus make some variables visible. This
is used inside Scilab to define variables on the caller and mimic the library loading behavior.

--
Clément



More information about the users mailing list