[Scilab-users] Executing scripts with functions from GUI
JLan
j-lan at online.no
Mon Apr 18 12:14:40 CEST 2016
I wonder if someone can give me a hint here.
I am trying to make a menu GUI that can start different scripts.
This does not work properly when the scripts contain functions.
A simple example. I have a script called
aaa.sce :
//-------------------
disp('Script aaa')
function afun(aa)
if aa=='-a' then
disp('AFUN')
end
endfunction
//-------------------
After executing this from the console:
*-->exec('aaa.sce', -1)*
I can obviously do:
*
1
Script aaa
-->afun -a
AFUN
*
I then clear afun and try to start this from my GUI
maingui.sce:
//----------------------------------------------------------
clear afun
function sel(al)
disp(al);
if al==1 then
exec('aaa.sce',-1)
end
if al==2 then
exec('bbb.sce',-1)
end
if al==3 then
disp('D_Spare')
end
set(hl, 'value', []);
endfunction
ctrw=figure(...
'figure_position',[-1,-1],...
'figure_size', [620,400],...
'figure_name', '',...
'menubar_visible','off',...
'toolbar_visible','off');
ht1=uicontrol(ctrw,...
'style','text',...
'position', [10 310 100 30],...
'string',' MAIN MENU');
hl=uicontrol(ctrw,'style','listbox', ...
'position', [10 10 550 280],...
'callback','sel(get(hl,''value''))');
set(hl, 'string',"...
Run aaa|...
Run bbb|...
spare");
//-----------------------------------------
When running
*-->exec('maingui.sce', -1)*
then clicking aaa and trying to run afun I get:
*
1.
Script aaa
-->afun -a
!--error 4
Undefined variable: afun*
I have tried to define afun as global, it has an effect but I still don't
get the same response.
Jan Å
--
View this message in context: http://mailinglists.scilab.org/Executing-scripts-with-functions-from-GUI-tp4033997.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
More information about the users
mailing list