<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Claus,<br>
<br>
For small dialogs to ask inputs, use <b>x_mdialog</b> function (
<a class="moz-txt-link-freetext" href="http://help.scilab.org/docs/5.5.0/fr_FR/x_mdialog.html">http://help.scilab.org/docs/5.5.0/fr_FR/x_mdialog.html</a> )<br>
<tt><br>
</tt><tt>function result = compute_voltage()</tt><tt><br>
</tt><tt> txt = ['Power (Watt)';'Impedance (ohm)'];</tt><tt><br>
</tt><tt> values = <b>x_mdialog</b>('System
values',txt,['100';'8'])</tt><tt><br>
</tt><tt> if values <> [] then</tt><tt><br>
</tt><tt> w = values(1);</tt><tt><br>
</tt><tt> o = values(2);</tt><tt><br>
</tt><tt> w = eval(w);</tt><tt><br>
</tt><tt> o = eval(o);</tt><tt><br>
</tt><tt><br>
</tt><tt> if typeof(w) <> "constant" | int(w)
<> w | typeof(o) <> "constant" | int(o) <> o
then</tt><tt><br>
</tt><tt> error("bad value, integer values expected");</tt><tt><br>
</tt><tt> end</tt><tt><br>
</tt><tt><br>
</tt><tt> result = sqrt(w * o);</tt><tt><br>
</tt><tt> else</tt><tt><br>
</tt><tt> result = [];</tt><tt><br>
</tt><tt> end</tt><tt><br>
</tt><tt>endfunction</tt><tt><br>
</tt><tt><br>
</tt><tt>voltage = compute_voltage()</tt><tt><br>
</tt><br>
Antoine<br>
<br>
<br>
Le 31/05/2014 22:01, Claus Futtrup a écrit :<br>
</div>
<blockquote cite="mid:538A34FD.1050505@gmail.com" type="cite">Hi
there
<br>
<br>
I hope someone can help me make a simple GUI front end to my
script, preferably without using GUI Builder or guimaker, because
I think I'll understand better without using additional tools.
<br>
<br>
The GUI - a window containing two variable input:
<br>
1. text + input box + text
<br>
Again the input is a number, typically an integer (as in
"system power : 100 Watt"). 100 being the user variable input.
<br>
2. text + input box + text
<br>
A number, typically an intereger (as in "impedance : 8 ohm"). 8
being the user variable input.
<br>
<br>
The script will then based on 100 Watt into 8 ohm calculate the
voltage = sqrt(100*8). I will round the number to one decimal,
convert it to a string and create an answer, like "Input level :
28.3 Volt".
<br>
<br>
The GUI should contain two buttons, e.g. an OK + a QUIT button.
The OK button runs the calculations. The quit button quits the
script (may as well quit Scilab).
<br>
<br>
I've studied the GUI controls in Scilab already and I understand
the the old way of making a new window is:
<br>
<br>
f = figure();
<br>
<br>
but it seems there's a new command in Scilab 5.5.0:
<br>
<br>
f = createWindow();
<br>
<br>
The new method probably has its advantages, but the Scilab manual
doesn't really explain... can anybody explain to me?
<br>
<br>
Can you use the same uicontrol commands with both methods? (can I
use examples found on the internet using "figure" and just replace
figure with createWindow?). It seems to me that the examples in
the createWindow gives uicontrol some inputs named "units" -
"normalized" - etc. - which are not present when looking at old
figure() examples.
<br>
<br>
My next question will be, how do I create a uicontrol which
accepts a string input (as I need 2 of those). The uicontrol
documentation says the "Edit" style will do that. Funny, but also
a bit strange, that you can find all sorts of examples for using
uicontrol with checboxes, listboxes, radiobuttons, pushbuttons,
tables etc. - but no examples are provided with this most useful
editable string input ... (???)
<br>
<br>
... hereafter I expect to evaluate the two strings (or if they're
returned as numbers, that's fine of course, I just don't need the
script to crash if something is not right). Then execute my code.
<br>
<br>
Best regards,
<br>
Claus
<br>
<br>
---
<br>
This email is free from viruses and malware because avast!
Antivirus protection is active.
<br>
<a class="moz-txt-link-freetext" href="http://www.avast.com">http://www.avast.com</a>
<br>
<br>
_______________________________________________
<br>
users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="200">--
Antoine ELIAS
Software developer
-----------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles
Phone: 01.80.77.04.70
<a class="moz-txt-link-freetext" href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a></pre>
</body>
</html>