[Scilab-users] user terminate program (exit while loop)

aweeks at hidglobal.com aweeks at hidglobal.com
Fri Jun 27 19:23:47 CEST 2014


Hi Pascal,

Further to my previous e-mail, I tested a few ideas.
If you add a print statement to the StopLoop function you can see what
values come back as the mouse is moved.

function StopLoop(win, x, y, ibut)
    global stoploop;

    mprintf(" win: %d  x: %d  y: %d  ibut: %d\n", win, x, y, ibut)

    if ibut == -1000 then stoploop = %t; end
    if ibut == 3 then
        stoploop = %t;
        mprintf("Loop stopped.\n");
    end
endfunction

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.
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'.

To anyone else who may be reading this:

	Is there a way to switch the 'windows focus' onto a particular window
from within the running SciLab program?

	Is there any chance that a function equivalent to the Borland Turbo C
function 'kbhit' could be added to future versions of SciLab?

Best wishes,
Adrian.

                                          
 Adrian Weeks                             
 Development Engineer                     
                                          
                                          
 HID Global,                              
 3 Cae Gwyrdd,                            
 Green Meadow Springs                     
 Business Park,                           
 Cardiff CF15 7AB,                        
 United Kingdom.                          
 +44 (0)29 20528523                       
 (Office)                                 
 aweeks at hidglobal.com                     
 www.hidglobal.com                        
                                          





                                                                                                                                  
  From:       "Fahrni Pascal (fahn)" <fahn at zhaw.ch>                                                                               
                                                                                                                                  
  To:         "users at lists.scilab.org" <users at lists.scilab.org>                                                                   
                                                                                                                                  
  Date:       25/06/2014 21:15                                                                                                    
                                                                                                                                  
  Subject:    [Scilab-users] user terminate program (exit while loop)                                                             
                                                                                                                                  
  Sent by:    "users" <users-bounces at lists.scilab.org>                                                                            
                                                                                                                                  





Dear scilab users,

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?

Best wishes
Pascal
 _______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140627/f0b970c3/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 32475108.gif
Type: image/gif
Size: 4559 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20140627/f0b970c3/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20140627/f0b970c3/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20140627/f0b970c3/attachment-0002.gif>


More information about the users mailing list