Pausable script

Hi everyone,

I'm trying to build a script that writes something every 2 minutes. This
is what I have so far, but I would like to make it so that I can pause
it, with a certain key, and make it continue with another key. When it
is unpaused it should keep track where it left off.

Any ideas how to do this?

40.times do |i|
    puts i
    sleep(200);
    puts "write something"
end

Ted

···

--
Posted via http://www.ruby-forum.com/.

You could replace the sleep(200) with a loop doing something like:
sleeping a small amount of time (e.g.: 100ms), checking if there's
user input available, act accordingly and sleeping again.

···

On Mon, Oct 25, 2010 at 3:26 PM, Ted Flethuseo <flethuseo@gmail.com> wrote:

Hi everyone,

I'm trying to build a script that writes something every 2 minutes. This
is what I have so far, but I would like to make it so that I can pause
it, with a certain key, and make it continue with another key. When it
is unpaused it should keep track where it left off.

Any ideas how to do this?

40.times do |i|
puts i
sleep(200);
puts "write something"
end

--
Luis Parravicini
http://ktulu.com.ar/blog/