Hi Stéphane and Antoine,
thank you for your prompt response. I tried resume but maybe I did not understand a callback at all.
My software:
The caller shortened => DM_datamenu.sci
Start it in the toolbox.start file with DM_datamenu("start")
----->
function [] = DM_datamenu(action)
[lhs,rhs]=argn();
...
if (rhs==1) & (typeof(action)=='constant') then
if action == 1 then
exec(fullfile(path,"macros","sce", "Read.sce"),-1);
end
... end
if (rhs==1) & (typeof(action)=='string') & (action="" then
addmenu('Data',["Read"],list(2,"DM_datamenu"));
end
...
endfunction
<-----The script shortend => Read.sce
----->
...
// Get some parameters for interpreting the csv file and the name of the output matrix
labels=["Name of matrix where Scilab saves the data", ...];
datlist=list("str", 1, ... );
values=["mat", ...];
[ok, mat_name, ...] = getvalue("CSV and Scilab parameters", labels, datlist, values);
// Read the data file according to the parameters from the GUI and store it in the matrix
// variable of the name specified in the GUI and stored in the string variable "mat_name"
execstr(mat_name + " = csvRead(fn, fld_sep, dec, [], substitute, [], [], headernum);");
...
execstr(mat_name + "= resume(mat_name)"); // DOES NOT WORK
<------
When I run the SCE script directly I have "mat" contaning the data available in the console (if I didn't changed the name in the GUI).
@Antoine: Maybe I do not understand a callback. I added execstr(mat_name + "= resume(mat_name)"); (see above) but it does not work.
Thanks, Hani
Gesendet: Freitag, 10. Mai 2019 um 14:43 Uhr
Von: "Antoine ELIAS" <antoine.el...@scilab-enterprises.com>
An: users@lists.scilab.org
Betreff: Re: [Scilab-users] Make Variable visible in Scilab from a SCE-script in a toolbox
Von: "Antoine ELIAS" <antoine.el...@scilab-enterprises.com>
An: users@lists.scilab.org
Betreff: Re: [Scilab-users] Make Variable visible in Scilab from a SCE-script in a toolbox
Hello,
You can use "resume" to return values in caller environment.
In case of callbacks from gui interaction, caller is always "console" scope.
In your callback do something like "data = ""> That's create or overwrite "data" with the contents of "a"
Example :
xdel(winsid());
clear createGUI callbackFromGui;
function createGUI()
f = figure(...
"dockable", "off", ...
"axes_size", [300 100], ...
"infobar_visible", "off", ...
"toolbar", "none", ...
"menubar_visible", "on", ...
"menubar", "none", ...
"default_axes", "off", ...
"background", color(255, 255, 255));
uicontrol(f, ...
"style", "pushbutton", ...
"string", "Send variable in console context", ...
"position", [(300 - 200)/2 (100 - 25)/2 200 25], ...
"callback", "callbackFromGui");
endfunction
function callbackFromGui()
a = rand(10, 10);
data = "">
endfunction
createGUI();
After clicking on the button, you should have a "data" variable in the console.
You can use "resume" to return values in caller environment.
In case of callbacks from gui interaction, caller is always "console" scope.
In your callback do something like "data = ""> That's create or overwrite "data" with the contents of "a"
Example :
xdel(winsid());
clear createGUI callbackFromGui;
function createGUI()
f = figure(...
"dockable", "off", ...
"axes_size", [300 100], ...
"infobar_visible", "off", ...
"toolbar", "none", ...
"menubar_visible", "on", ...
"menubar", "none", ...
"default_axes", "off", ...
"background", color(255, 255, 255));
uicontrol(f, ...
"style", "pushbutton", ...
"string", "Send variable in console context", ...
"position", [(300 - 200)/2 (100 - 25)/2 200 25], ...
"callback", "callbackFromGui");
endfunction
function callbackFromGui()
a = rand(10, 10);
data = "">
endfunction
createGUI();
After clicking on the button, you should have a "data" variable in the console.
Regards,
Antoine
Le 10/05/2019 à 14:18, Stéphane Mottelet a écrit :
Le 10/05/2019 à 11:42, Hani Andreas Ibrahim a écrit :I wrote a SCE-Script where you can read datafiles into a matrix and specify the import parameter AND the name of matrix where the data is stored in a GUI. Because variables in sce are visible to Scilab I could work with the matrix which name was specified in the GUI in Scilab's console.Now I wrote a toolbox where I call this script from a menu item (addmenu) with exec("myscrip.sce",-1). The toolbox works fine so far and run the script properly but the matrix variable is not visible in Scilab. Obviously Scilab handles variables in sce in a toolbox differently?The script itself works fine and provide the variable if I run the sce directly outside the toolbox. The sce has no dependencies to external SCIs.Who can I make this variable visible for Scilab from a toolbox?Thanks, HaniPS: The toolbox should run on Scilab 5.5.x and 6.0.x._______________________________________________ users mailing list users@lists.scilab.org https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/usersHello,
Please give us a small and reproductive example, under the form of two scripts (the one creating the menu and the one executed by selecting the menu item).
S.
-- 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_______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
_______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
_______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users