Pausable script

T

Ted Flethuseo

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
 
L

Luis Parravicini

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|
=A0 =A0puts =A0i
=A0 =A0sleep(200);
=A0 =A0puts "write something"
end

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.


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top