<html><body>
<p><font size="2" face="sans-serif">Hi Pascal,</font><br>
<br>
<font size="2" face="sans-serif">I've wanted to do this too.</font><br>
<font size="2" face="sans-serif">You might like to look at link <a href="http://compgroups.net/comp.soft-sys.math.scilab/non-blocking-keyboard-input/2083213">http://compgroups.net/comp.soft-sys.math.scilab/non-blocking-keyboard-input/2083213</a></font><br>
<font size="2" face="sans-serif">which is very similar to Samuel Gougeon's suggestion.</font><br>
<br>
<font size="2" face="sans-serif">Samuel says his proposal is untested but I use this method and it works for me. I've pasted the basis of my code below and apologise if it doesn't work in your setup because I position the windows and text boxes to suit the layout on my monitor. If you have a question feel free to ask.</font><br>
<br>
<br>
<font size="2" face="sans-serif">global</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">figrhdl</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif">global</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">stophdl</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif">global</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">stoploop</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif"><br>
</font><font size="2" face="sans-serif">function</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif"><u>StopLoop</u></font><font size="2" face="sans-serif">(</font><font size="2" face="sans-serif">win</font><font size="2" face="sans-serif">, </font><font size="2" face="sans-serif">x</font><font size="2" face="sans-serif">, </font><font size="2" face="sans-serif">y</font><font size="2" face="sans-serif">, </font><font size="2" face="sans-serif">ibut</font><font size="2" face="sans-serif">)</font><font size="2" face="sans-serif"><br>
</font><font size="2" face="sans-serif">global</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">stoploop</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">if</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">ibut</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">==</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">-</font><font size="2" face="sans-serif">1000</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">then</font><font size="2" face="sans-serif"> stoploop </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">%t</font><font size="2" face="sans-serif">; </font><font size="2" face="sans-serif">end</font><font size="2" face="sans-serif"><br>
</font><font size="2" face="sans-serif">if</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">ibut</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">==</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">3</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">then</font><font size="2" face="sans-serif"><br>
stoploop </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">%t</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif">mprintf</font><font size="2" face="sans-serif">(</font><font size="2" face="sans-serif">"Loop stopped.\n"</font><font size="2" face="sans-serif">)</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif">end</font><font size="2" face="sans-serif"><br>
</font><font size="2" face="sans-serif">endfunction</font><font size="2" face="sans-serif"><br>
<br>
</font><font size="2" face="sans-serif">function</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif"><u>StartDisplay</u></font><font size="2" face="sans-serif">(</font><font size="2" face="sans-serif">)</font><font size="2" face="sans-serif"><br>
</font><font size="2" face="sans-serif">global</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">figrhdl</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">global</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">stophdl</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif"> figrhdl </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif"><u>scf</u></font><font size="2" face="sans-serif">(</font><font size="2" face="sans-serif">1</font><font size="2" face="sans-serif">)</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">xstring</font><font size="2" face="sans-serif">(</font><font size="2" face="sans-serif">-</font><font size="2" face="sans-serif">0.1</font><font size="2" face="sans-serif">,</font><font size="2" face="sans-serif">1.1</font><font size="2" face="sans-serif">,</font><font size="2" face="sans-serif">"LEFT CLICK HERE TO STOP LOOPING"</font><font size="2" face="sans-serif">)</font><font size="2" face="sans-serif">;<br>
stophdl </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif"><u>gce</u></font><font size="2" face="sans-serif">()</font><font size="2" face="sans-serif">;<br>
stophdl</font><font size="2" face="sans-serif">.</font><font size="2" face="sans-serif">font_style</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">0</font><font size="2" face="sans-serif">;<br>
stophdl</font><font size="2" face="sans-serif">.</font><font size="2" face="sans-serif">font_size</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">2</font><font size="2" face="sans-serif">;<br>
stophdl</font><font size="2" face="sans-serif">.</font><font size="2" face="sans-serif">box</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">'on'</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif"><br>
</font><font size="2" face="sans-serif"><u>seteventhandler</u></font><font size="2" face="sans-serif">(</font><font size="2" face="sans-serif">'StopLoop'</font><font size="2" face="sans-serif">)</font><font size="2" face="sans-serif">;<br>
figrhdl</font><font size="2" face="sans-serif">.</font><font size="2" face="sans-serif">event_handler</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">'StopLoop'</font><font size="2" face="sans-serif">;<br>
figrhdl</font><font size="2" face="sans-serif">.</font><font size="2" face="sans-serif">event_handler_enable</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">'on'</font><font size="2" face="sans-serif">;<br>
</font><font size="2" face="sans-serif">endfunction</font><br>
<br>
<font size="2" face="sans-serif">stoploop </font><font size="2" face="sans-serif">=</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">%f</font><font size="2" face="sans-serif">; // The endless loop which is to be stopped.<br>
</font><font size="2" face="sans-serif">while</font><font size="2" face="sans-serif"> </font><font size="2" face="sans-serif">~</font><font size="2" face="sans-serif">stoploop </font><font size="2" face="sans-serif">do</font><font size="2" face="sans-serif"><br>
.... whatever<br>
</font><font size="2" face="sans-serif">end</font><br>
<font size="2" face="sans-serif"><br>
</font>
<table border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td class="t" width="178" valign="middle">
<ul style="padding-left: 1pt"><font size="2" color="#333333" face="Arial"><b>Adrian Weeks </b></font><font size="1" color="#666666" face="Arial"><br>
Development Engineer <br>
<br>
<br>
HID Global,<br>
3 Cae Gwyrdd,<br>
Green Meadow Springs<br>
Business Park,<br>
Cardiff CF15 7AB,<br>
United Kingdom.<br>
+44 (0)29 20528523 (Office)</font><font size="1" color="#0000FF" face="Arial"><u><br>
</u></font><a href="mailto:aweeks@hidglobal.com"><font size="1" color="#0000FF" face="Arial"><u>aweeks@hidglobal.com</u></font></a><font size="1" color="#0000FF" face="Arial"><u><br>
</u></font><a href="http://www.hidglobal.com/"><font size="1" color="#0000FF" face="Arial"><u>www.hidglobal.com</u></font></a></ul>
</td><td width="139" valign="middle">
<ul style="padding-left: 1pt"><a href="http://www.hidglobal.com/"><img src="cid:1__=0FBBF797DFDA56288f9e8a93df93869@prox.com" width="130" height="170" border="0"></a></ul>
</td></tr>
</table>
<br>
<br>
<img width="16" height="16" src="cid:2__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt="Inactive hide details for "Fahrni Pascal (fahn)" ---25/06/2014 21:15:46---Dear scilab users, I'm using a scilab script to monit"><font size="2" color="#424282" face="sans-serif">"Fahrni Pascal (fahn)" ---25/06/2014 21:15:46---Dear scilab users, I'm using a scilab script to monitor a serial port, read from it and do some calc</font><br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">From:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<font size="1" face="sans-serif">"Fahrni Pascal (fahn)" <fahn@zhaw.ch></font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">To:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<font size="1" face="sans-serif">"users@lists.scilab.org" <users@lists.scilab.org></font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Date:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<font size="1" face="sans-serif">25/06/2014 21:15</font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Subject:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<font size="1" face="sans-serif">[Scilab-users] user terminate program (exit while loop)</font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Sent by:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:3__=0FBBF797DFDA56288f9e8a93df93869@prox.com" border="0" alt=""><br>
<font size="1" face="sans-serif">"users" <users-bounces@lists.scilab.org></font></td></tr>
</table>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
<font size="2" face="Calibri">Dear scilab users,</font><br>
<font size="2" face="Calibri"> </font><br>
<font size="2" face="Calibri">I’m using a scilab script to monitor a serial port, read from it and do some calculations based on that data. The program is wrapped by a while loop and contains an xpause statement. What is the best way to allow the user to terminate the program by user input?</font><br>
<font size="2" face="Calibri"> </font><br>
<font size="2" face="Calibri">Best wishes</font><br>
<font size="2" face="Calibri">Pascal</font><br>
<font size="2" face="Calibri"> </font><tt><font size="2">_______________________________________________<br>
users mailing list<br>
users@lists.scilab.org<br>
</font></tt><tt><font size="2"><a href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a></font></tt><tt><font size="2"><br>
</font></tt><br>
<br>
</body></html>