<html><body>
<p><font size="2" face="sans-serif">Hi Pascal,</font><br>
<br>
<font size="2" face="sans-serif">Further to my previous e-mail, I tested a few ideas.</font><br>
<font size="2" face="sans-serif">If you add a print statement to the StopLoop function you can see what values come back as the mouse is moved.</font><br>
<br>
<font size="2" face="sans-serif">function </font><font size="2" face="sans-serif"><u>StopLoop</u></font><font size="2" face="sans-serif">(win, x, y, ibut)<br>
global stoploop;<br>
</font><br>
<font size="2" face="sans-serif"> mprintf(" win: %d x: %d y: %d ibut: %d\n", win, x, y, ibut)</font><br>
<br>
<font size="2" face="sans-serif"> if ibut == -1000 then stoploop = %t; end<br>
if ibut == 3 then<br>
stoploop = %t;<br>
mprintf("Loop stopped.\n");<br>
end<br>
endfunction<br>
</font><br>
<font size="2" face="sans-serif">Values are only returned when the mouse cursor is over the graphics window to which the event handler is attached. This is true even if the 'focus' is not on that window.</font><br>
<font size="2" face="sans-serif">However, no value seems to be returned when a keyboard key is pressed unless the 'focus' is on the graphics window and the mouse cursor is in the window. This is a little disappointing - it would have been nice to be able to 'press any key to stop loop'.</font><br>
<br>
<font size="2" face="sans-serif">To anyone else who may be reading this:</font><br>
<br>
<font size="2" face="sans-serif"> Is there a way to switch the 'windows focus' onto a particular window from within the running SciLab program?</font><br>
<br>
<font size="2" face="sans-serif"> Is there any chance that a function equivalent to the Borland Turbo C function 'kbhit' could be added to future versions of SciLab?</font><br>
<br>
<font size="2" face="sans-serif">Best wishes,</font><br>
<font size="2" face="sans-serif">Adrian.</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__=0FBBF797DFCDAD108f9e8a93df93869@prox.com" width="130" height="170" border="0"></a></ul>
</td></tr>
</table>
<br>
<br>
<img width="16" height="16" src="cid:2__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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__=0FBBF797DFCDAD108f9e8a93df93869@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>