[Scilab-users] Variables visibility in functions

Stéphane Mottelet stephane.mottelet at utc.fr
Thu May 7 17:05:23 CEST 2020


Here is a small example. Although the name of fields of returned struct 
is very cryptic, the information you need can be easily recovered.


mputl(["function [y] = foo(x)"
"y = x + a"
"y = y + b"
"endfunction"],"slint_test.sci")
out  =  slint("slint_test.sci",%f)
if  isfield(out.info,"00003.Uninitialized")
     s  =  out.info("00003.Uninitialized");
     for  i=1:length(s)
         disp(s(i).msg)
     end
end

S.

Le 07/05/2020 à 14:40, Stéphane Mottelet a écrit :
> Hi,
>
> Use Scilab slint tool:
>
> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/help.scilab.org/docs/6.1.0/en_US/slint.html 
>
>
> S.
>
> Le 07/05/2020 à 14:01, kjubo a écrit :
>> Dear all,
>>
>> I would like to ask you, how can I disable visibility of variables from
>> workspace for functions.
>>
>> I need to be sure, that function which I convert from script file, 
>> will not
>> use any variable, which is not in it input, or defined inside the 
>> function
>> itself.
>>
>> Please see examples below.
>>
>> Is this possible?
>>          Thank you
>>          BR
>>          JK
>>
>>          example 1:
>>
>>          a = 3
>>          function fx = some_fun(x,a)
>>              fx = x+a
>>          endfunction
>>
>>          calling some_fun(5) now return 3+5, but I need to be an error.
>>
>>
>>          example 2:
>>
>>          a = 3
>>          function fx = some_fun(x)
>>              fx = x+a
>>          endfunction
>>
>>          I need also error, as variable a should be passed as input 
>> argument
>> or defined inside some_fun body
>>
>>
>>
>> -- 
>> Sent from: 
>> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 
>>
>
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200507/836998ee/attachment.htm>


More information about the users mailing list