Hi,

I know that with readlines you can start executing a code upon user input.
What I would like to do is to have the ability to abort a code based on a
new user input. E.g. when the user hits enter the code stops running. That
is, I would periodically check for a user input and stop the code when the
correct input was entered.

Below is an example of a function which would run an endless loop but check
in each iteration if there was a new user input which would abort it. It
does not do the right thing obviously but maybe someone can point out how
this can be done.

startSystem <- function(){

    cat("Processing code, hit ENTER to stop.")
    i=a=n=1
    while(!is.na(n)){
      a=i+a
      i=i+1
      n = readline("")
    }
    return(NULL)

}

Thanks!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to