[scilab-Users] global variable - Graphic interface

Stephane Mottelet stephane.mottelet at utc.fr
Sat Jan 15 15:57:26 CET 2011


Jean-Louis Auge <Jean-Louis.Auge at grenoble.cnrs.fr> a écrit :

> I used the command 'global' but I surprised by its use.
> Indeed, I have to define my variable as 'global' in the main program  
> AND in the function where it has to be computed.
> Is it normal?
> From my point of view, I thought that to define the global variable  
> in the main program was sufficient!

In Scilab, all variables of the calling workspace are accessible
but read-only. If such a variable is modified e.g. inside a function,
this is in fact a local copy which is modified, not the variable of
the calling workspace. This explains the way that global variable
work in Scilab. If your variable is declared global in the calling
workspace, but not inside the function, when you modify the variable
in the function, you modify a local variable.

S.

>
> Nota: The function is a callback function from a pushbutton.
>
> Regards,
>
> JL.
>
>
>
> Calixte Denizet a écrit :
>> Hello Jean-Louis,
>>
>> Maybe in using the command 'global' (help global)
>>
>> Calixte
>>
>> Le vendredi 14 janvier 2011 à 23:26 +0100, Jean-Louis Auge a écrit :
>>
>>> Hi,
>>>
>>> I would like use the result from calculations made in a function  
>>> called by a pressbutton.
>>> For that, I defined the result as a global variable so that all my  
>>> program sees it.
>>> Unfortunately, the program does not see this global variable; as  
>>> if it cannot exit from the function.
>>>
>>> Is somebody have an idea on that?
>>>
>>>
>>> Best regards.
>>>
>>> JL
>>>
>





More information about the users mailing list