<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Hi Stéphane and Antoine,</div>

<div> </div>

<div>thank you for your prompt response. I tried <span style="font-family:Courier New,Courier,monospace;">resume </span>but maybe I did not understand a callback at all.</div>

<div> </div>

<div>My software:</div>

<div> </div>

<div>The caller shortened => DM_datamenu.sci</div>

<div>Start it in the toolbox.start file with DM_datamenu("start")</div>

<div> </div>

<div>-----></div>

<div> </div>

<div><span style="font-family:Courier New,Courier,monospace;">function [] = DM_datamenu(action)</span></div>

<div><span style="font-family:Courier New,Courier,monospace;">[lhs,rhs]=argn();</span><!--EndFragment--></div>

<div>...</div>

<div> </div>

<div><span style="font-family:Courier New,Courier,monospace;">if (rhs==1) & (<span style="text-decoration: underline;">typeof</span>(action)=='constant') then </span>

<pre style="font-family:Lucida Console;font-style:normal;font-size:13.0;"><span style="font-family:Courier New,Courier,monospace;">        if action == 1 then
            exec(<span style="text-decoration: underline;">fullfile</span>(path,"macros","sce", "Read.sce"),-1);
        end

        ...

end</span></pre>

<div><span style="font-family:Courier New,Courier,monospace;">if (rhs==1) & (<span style="text-decoration: underline;">typeof</span>(action)=='string') & (action=='start') then </span>

<pre style="font-family:Lucida Console;font-style:normal;font-size:13.0;"><span style="font-family:Courier New,Courier,monospace;">        <span style="text-decoration: underline;">addmenu</span>('Data',["Read"],list(2,"DM_datamenu"));
end</span></pre>

<div><span style="font-family:Courier New,Courier,monospace;">...</span></div>

<div> </div>

<div><span style="font-family:Courier New,Courier,monospace;">endfunction</span></div>
<!--EndFragment--><-----</div>
</div>

<div> </div>

<div>The script shortend => Read.sce</div>

<div> </div>

<div>-----></div>

<div> </div>

<div><span style="font-family:Courier New,Courier,monospace;">...</span></div>

<div> </div>

<div><span style="font-family:Courier New,Courier,monospace;">// Get some parameters for interpreting the csv file and the name of the output matrix </span>

<pre style="font-family:Lucida Console;font-style:normal;font-size:13.0;"><span style="font-family:Courier New,Courier,monospace;">labels=["Name of matrix where Scilab saves the data", ...];
datlist=list("str", 1, ... );
values=["mat", ...];
[ok, mat_name, ...] = <span style="text-decoration: underline;">getvalue</span>("CSV and Scilab parameters", labels, datlist, values);</span></pre>

<div><span style="font-family:Courier New,Courier,monospace;">// Read the data file according to the parameters from the GUI and store it in the matrix </span></div>

<div><span style="font-family:Courier New,Courier,monospace;">// variable of the name specified in the GUI and stored in the string variable "mat_name"</span></div>

<div><span style="font-family:Courier New,Courier,monospace;">execstr(mat_name + " = csvRead(fn, fld_sep, dec, [], substitute, [], [], headernum);");</span><!--EndFragment--></div>

<div> </div>

<div><span style="font-family:Courier New,Courier,monospace;">...</span></div>

<div> </div>

<div><span style="font-family:Courier New,Courier,monospace;">execstr(mat_name + "= resume(mat_name)"); // DOES NOT WORK</span></div>

<div> </div>

<div><------</div>

<div> </div>

<div>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).</div>

<div> </div>

<div>@Antoine: Maybe I do not understand a callback. I added <span style="font-family:Courier New,Courier,monospace;">execstr(mat_name + "= resume(mat_name)"); </span>(see above) but it does not work.</div>

<div> </div>

<div> </div>
<!--EndFragment--></div>

<div>Thanks, Hani</div>

<div> 
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Freitag, 10. Mai 2019 um 14:43 Uhr<br/>
<b>Von:</b> "Antoine ELIAS" <antoine.elias@scilab-enterprises.com><br/>
<b>An:</b> users@lists.scilab.org<br/>
<b>Betreff:</b> Re: [Scilab-users] Make Variable visible in Scilab from a SCE-script in a toolbox</div>

<div name="quoted-content">
<div style="background-color: rgb(255,255,255);">
<div>Hello,<br/>
<br/>
You can use "resume" to return values in caller environment.<br/>
In case of callbacks from gui interaction, caller is always "console" scope.<br/>
<br/>
In your callback do something like "data = resume(a);"<br/>
That's create or overwrite "data" with the contents of "a"<br/>
<br/>
Example :<br/>
<br/>
<tt>xdel(winsid());</tt><br/>
<tt>clear createGUI callbackFromGui;</tt><br/>
<br/>
<tt>function createGUI()</tt><br/>
<tt>    f = figure(...</tt><br/>
<tt>        "dockable", "off", ...</tt><br/>
<tt>        "axes_size", [300 100], ...</tt><br/>
<tt>        "infobar_visible", "off", ...</tt><br/>
<tt>        "toolbar", "none", ...</tt><br/>
<tt>        "menubar_visible", "on", ...</tt><br/>
<tt>        "menubar", "none", ...</tt><br/>
<tt>        "default_axes", "off", ...</tt><br/>
<tt>        "background", color(255, 255, 255));</tt><br/>
<br/>
<tt>    uicontrol(f, ...</tt><br/>
<tt>        "style", "pushbutton", ...</tt><br/>
<tt>        "string", "Send variable in console context", ...</tt><br/>
<tt>        "position", [(300 - 200)/2 (100 - 25)/2 200 25], ...</tt><br/>
<tt>        "callback", "callbackFromGui");</tt><br/>
<tt>endfunction</tt><br/>
<br/>
<tt>function callbackFromGui()</tt><br/>
<tt>    a = rand(10, 10);</tt><br/>
<tt>    data = resume(a);</tt><br/>
<tt>endfunction</tt><br/>
<br/>
<tt>createGUI();</tt><br/>
<br/>
After clicking on the button, you should have a "data" variable in the console.</div>

<div><br/>
<br/>
Regards,<br/>
Antoine</div>

<div class="moz-cite-prefix">Le 10/05/2019 à 14:18, Stéphane Mottelet a écrit :</div>

<blockquote>
<div class="moz-cite-prefix">Le 10/05/2019 à 11:42, Hani Andreas Ibrahim a écrit :</div>

<blockquote>
<div style="font-family: Verdana;font-size: 12.0px;">
<div>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.</div>

<div> </div>

<div>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?</div>

<div> </div>

<div>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.</div>

<div> </div>

<div>Who can I make this variable visible for Scilab from a toolbox?</div>

<div> </div>

<div>Thanks, Hani</div>

<div> </div>

<div>PS: The toolbox should run on Scilab 5.5.x and 6.0.x.</div>
</div>
 

<fieldset class="mimeAttachmentHeader"> </fieldset>

<pre class="moz-quote-pre">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org" onclick="parent.window.location.href='mailto:users@lists.scilab.org'; return false;" target="_blank">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users" target="_blank">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>

<p>Hello,</p>

<p>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).</p>

<p>S.</p>

<pre class="moz-signature">--
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
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet" target="_blank">http://www.utc.fr/~mottelet</a></pre>
 

<fieldset class="mimeAttachmentHeader"> </fieldset>

<pre class="moz-quote-pre">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org" onclick="parent.window.location.href='mailto:users@lists.scilab.org'; return false;" target="_blank">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br/>
_______________________________________________ users mailing list users@lists.scilab.org <a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a></div>
</div>
</div>
</div>
</div></div></body></html>