Hi,

I hope I will not bother you.

This is a useful tool in programming pauses:

function(ask) {
if (ask & interactive() & sink.number()==0) readline("\nType <Return>\t to continue : ")
}


It guards against batch use and sink-ing:

for (ii in 1:5) {
    cat(ii,"\n")
    waitReturn(ii %% 2 == 1)
  }

sink("blafile")
for (ii in 1:5) {
    cat(ii,"\n")
    waitReturn(ii %% 2 == 1)
  }
sink()
#look at file "blafile"

Documentation: (R style)
\name{waitReturn}
\alias{waitReturn}
\title{Wait for <Return>}
\description{
Wait for the user to type <Return>, depending on argument.
}
\usage{
waitReturn(ask=TRUE)
}
\arguments{
\item{ask}{ \code{TRUE} will generate the interruption, \code{FALSE} will not.}
}
\details{
The interruption will only generated for the interactive use of R and
if the call is not \code{sink}ed (where it would hang the process).
}
\value{
None.
}


\examples{
  for (ii in 1:5) {
    cat(ii,"\n")
    waitReturn(ii %% 2 == 1)
  }
}
\author{Christian W. Hoffmann, [EMAIL PROTECTED],
        \url{http://www.wsl.ch/staff/christian.hoffmann}
}
\keyword{programming}


Christian



--
-- --> New telephone number, old one will work until 2006
Dr.sc.math.Christian W. Hoffmann, http://www.wsl.ch/staff/christian.hoffmann
Mathematics + Statistical Computing e-mail: [EMAIL PROTECTED]
Swiss Federal Research Institute WSL Tel: ++41-44-73922.. ..77 (self)
CH-8903 Birmensdorf, Switzerland ..11(exchange), ..15 (Fax)


______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to