How can I offer 5 seconds to the user to write something in order to ask for a pause of indefinite length. If the pause is not demanded within these 5 seconds, the process continues. If a pause is demanded, then the user has all the time (s)he needs and (s)he can hit "enter" in order to resume the process whenever (s)he wants.
The interest of such functionality is that if the user is absent, the pause lasts for 5 seconds only. And if the user is present, then (s)he can enjoy a pause in order to watch the graph that has been produced for example.
The code may eventually look like that:
DoYouWantaPause = function(){
myprompt = "You have 5 seconds to write the letter <p>. If you don't the process will go on."
foo = readline(prompt = myprompt, killAfter = 5 Seconds) # give 5 seconds to the user. If the user enter a letter, then this letter is stored in `foo`.
if (foo == "p" | foo == "P") { # if the user has typed "p" or "P"
foo = readline(prompt = "Press enter when you want to resume the process") # Offer a pause of indefinite length
}
}
# Main
for (i in somelist){
...
DoYouWantaPause()
}