Loop interrupt

Loop interrupt

Post by javier_santama.. » Thu, 01 Mar 2001 18:19:49



Hi all!

I'd like to know How Can I stop a for-loop while
executing, pressing a key from the keyboard.
Which is the command that detects a key press?
Thank you very much

Javier

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts

 
 
 

Loop interrupt

Post by Pete Boettche » Thu, 01 Mar 2001 22:47:01



> I'd like to know How Can I stop a for-loop while
> executing, pressing a key from the keyboard.
> Which is the command that detects a key press?

If you put 'drawnow' or 'pause(0)' somewhere inside the for-loop,
Control-C should break out of the loop.  This approach requires very
little overhead.

-PB

 
 
 

Loop interrupt

Post by javier_santama.. » Fri, 02 Mar 2001 17:01:32


I mean without aborting the program execution!
(I want to go on with the calculations)




>> I'd like to know How Can I stop a for-loop while
>> executing, pressing a key from the keyboard.
>> Which is the command that detects a key press?

>If you put 'drawnow' or 'pause(0)' somewhere inside the for-loop,
>Control-C should break out of the loop.  This approach requires very
>little overhead.

>-PB

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts

 
 
 

Loop interrupt

Post by J.N. van der Gees » Sat, 03 Mar 2001 16:21:08


use try and catch, like in

try
  for ...
    ....
    pause(0) ;
  end % for
catch
  disp('Break out of for loop') ;
end
% remainder of program below

hth,
Jos


> I mean without aborting the program execution!
> (I want to go on with the calculations)




> >> I'd like to know How Can I stop a for-loop while
> >> executing, pressing a key from the keyboard.
> >> Which is the command that detects a key press?

> >If you put 'drawnow' or 'pause(0)' somewhere inside the for-loop,
> >Control-C should break out of the loop.  This approach requires very
> >little overhead.

> >-PB

>  -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
>   http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
>    NewsOne.Net prohibits users from posting spam.  If this or other posts


--

- J.N. van der Geest --------------------------------------
  Department of Physiology, Erasmus University
  PO Box 1738, NL-3000-DR, Rotterdam, The Netherlands
  voice: +31(0)10 408 7556 / fax: +31(0)10 408 9457
  www: http://www.eur.nl/fgg/fys/people/geest.htm

  Voicemail and faxmail: +31(0)20 866 3958
       (messages will be send to my email)
-----------------------------------------------------------

 
 
 

Loop interrupt

Post by J.N. van der Gees » Sat, 03 Mar 2001 17:05:50


use try and catch, like in

try
  for ...
    ....
    pause(0) ;
  end % for
catch
  disp('Break out of for loop') ;
end
% remainder of program below

hth,
Jos


> I mean without aborting the program execution!
> (I want to go on with the calculations)




> >> I'd like to know How Can I stop a for-loop while
> >> executing, pressing a key from the keyboard.
> >> Which is the command that detects a key press?

> >If you put 'drawnow' or 'pause(0)' somewhere inside the for-loop,
> >Control-C should break out of the loop.  This approach requires very
> >little overhead.

> >-PB

 
 
 

Loop interrupt

Post by Zdenek Hura » Fri, 02 Mar 2001 19:11:47


I am not quite sure, but it seems to me that the only feasible way is via
some UICONTROL. Just create a small GUI (containing only one button and
possible description) with a callback setting some switch on. Then, inside
the loop perform the test of the flag. If the flag is ON, then RETURN.

--zh


> I mean without aborting the program execution!
> (I want to go on with the calculations)




> >> I'd like to know How Can I stop a for-loop while
> >> executing, pressing a key from the keyboard.
> >> Which is the command that detects a key press?

> >If you put 'drawnow' or 'pause(0)' somewhere inside the for-loop,
> >Control-C should break out of the loop.  This approach requires very
> >little overhead.

> >-PB

>  -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the
eb  -----
>   http://newsone.net/ -- Free reading and anonymous posting to 60,000+
groups
>    NewsOne.Net prohibits users from posting spam.  If this or other posts
> made through NewsOne.Net violate posting guidelines, email