[Scilab-users] getting values from an event handler

Serge Steer Serge.Steer at inria.fr
Mon Dec 3 18:49:57 CET 2012


The event handling function works asynchronously (may be during the 
execution of another function....)
instruction like res=return (x*2) will store the result in the current 
execution context  which unknown if Scilab is not at prompt level when 
the handling function is executed



It is better to use global variable:
function myEventHandler(win,x,y,ibut)
global res
res=x*2
endfunction

You can then recover the value everywhere by
global res;disp(res)


or to store the result into the user data field of the figure in which 
the evenet handler has been called

function myEventHandler(win,x,y,ibut)
fig=get_figure_handle(win)
set(fig, "user_data", struct("myres",x*2))
endfunction
You can then recover the value everywhere using

fig=get_figure_handle(win)
disp(fig.user_data.myres)


Serge Steer


Le 30/11/2012 14:26, walid shouman a écrit :
> how can i return the a value from an event handling function
>
>
> ie:
>
> seteventhandler('myEventHandler(win,x,y,ibut)')
> function val=myEventHandler(win,x,y,ibut)
> return x*2
> endfunction
>
>
> where should i find "val" to use it later in the code ?
>
> -- 
>
> Sincerely,
> Walid E. Shouman
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

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


More information about the users mailing list