The R Project SVN R

Rev

Rev 56186 | Rev 67599 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/interactive.Rd
2
% Part of the R package, http://www.R-project.org
59039 ripley 3
% Copyright 1995-2009 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
2 r 6
\name{interactive}
56186 murdoch 7
\alias{interactive}
7081 pd 8
\title{Is R Running Interactively?}
50389 maechler 9
\description{
7782 hornik 10
  Return \code{TRUE} when \R is being used interactively and
11
  \code{FALSE} otherwise.
12
}
2 r 13
\usage{
14
interactive()
15
}
50376 ripley 16
\details{
17
  An interactive \R session is one in which it is assumed that there is
18
  a human operator to interact with, so for example \R can prompt for
19
  corrections to incorrect input or ask what to do next or if it is OK
20
  to move to the next plot.
21
 
22
  GUI consoles will arrange to start \R in an interactive session.  When
23
  \R is run in a terminal (via \command{Rterm.exe} on Windows), it
24
  assumes that it is interactive if \file{stdin} is connected to a
25
  (pseudo-)terminal and not if \file{stdin} is redirected to a file or
26
  pipe.  Command-line options \option{--interactive} (Unix) and
27
  \option{--ess} (Windows, \command{Rterm.exe}) override the default
28
  assumption.
29
#ifdef unix
50903 hornik 30
  (On a Unix-alike, whether the \code{readline} command-line editor is
50376 ripley 31
  used is \strong{not} overridden by \option{--interactive}.)
32
#endif
33
 
34
  Embedded uses of \R can set a session to be interactive or not.
35
 
36
  Internally, whether a session is interactive determines
37
  \itemize{
38
    \item how some errors are handled and reported, e.g. see
50389 maechler 39
    \code{\link{stop}} and \code{\link{options}("showWarnCalls")}.
40
 
50376 ripley 41
    \item  whether one of \option{--save}, \option{--no-save} or
42
    \option{--vanilla} is required, and if \R ever asks whether to save the
43
    workspace.
50389 maechler 44
 
50376 ripley 45
    \item the choice of default graphics device launched when needed and
50389 maechler 46
    by \code{\link{dev.new}}: see \code{\link{options}("device")}
47
 
50376 ripley 48
    \item whether graphics devices ever ask for confirmation of a new
49
    page.
50
  }
51
  In addition, \R's own \R code makes use of \code{interactive()}: for
52
  example \code{\link{help}}, \code{\link{debugger}} and
53
  \code{\link{install.packages}} do.
54
}
48662 ripley 55
\note{
56
  This is a \link{primitive} function.
57
}
2 r 58
\seealso{
7782 hornik 59
  \code{\link{source}},
60
  \code{\link{.First}}
2 r 61
}
62
\examples{
63
 .First <- function() if(interactive()) x11()
64
}
286 maechler 65
\keyword{environment}
66
\keyword{programming}