Re: [R] break loop with keypress

2014-08-06 Thread William Simpson
Thanks Greg. I guess another option is to call a C function directly. On Windows I see there is a function _kbhit() in conio.h. Not sure if it would be that simple. Write a .c file #include conio.h int main(void) { int ch; ch= _kbhit(); return ch; } Then do the necessary stuff to call

[R] break loop with keypress

2014-08-05 Thread William Simpson
This works, but it is not quite what I need: par(mar=rep(0,4)) while(1) { img1-matrix(runif(2500),50,50) dev.hold(); image(img1,useRaster=TRUE); dev.flush() img2-matrix(runif(2500),50,50) dev.hold(); image(img2,useRaster=TRUE); dev.flush() } I would like to do this: while(!kbhit())

Re: [R] break loop with keypress

2014-08-05 Thread Greg Snow
You could create a tcltk window that looks for a button click and/or key press and when that happens change the value of a variable. Then in your loop you just look at the value of the same variable and break when the value changes. On Tue, Aug 5, 2014 at 6:13 AM, William Simpson