.First
function and can create the
.Last
function if desired.
.First() .Last() .First.local()
.First
function are
called or evaluated when S-PLUS is started. These are generally used for their
side effects, which can include attaching directories, setting options, and
printing messages. The
.Last
function is called
or evaluated when S-PLUS is about to exit normally. It is not executed if
S-PLUS terminates abnormally.
The file
$SHOME/S.init
contains the standard S-PLUS initialization instructions.
DO NOT EDIT THIS FILE.
Local administrators can
edit the file $SHOME/local/S.init
to specify particular actions that should be performed at the start of S-PLUS sessions for all users at their site.
Examples include attaching a directory of local functions or setting options.
This is evaluated prior to an individual's
.First
,
so an individual may override the actions in
$SHOME/S.init and $SHOME/local/S.init.
The
.First.local
function, which a system
administrator can create in the system database library/splus,
provides another mechanism for this, although this is not recommended.
The S.init files are text files containing a braced set of one or
more S-PLUS expressions. The S_FIRST environment variable, if it
is set, replaces the
.First
function, if any.
If an error occurs when
.First
(or S_FIRST) is evaluated, then S-PLUS is started but some or all
of the actions are not taken.
If an error occurs when
.Last
(or S_LAST) is evaluated, then S-PLUS displays an error message
before exiting. Click OK to exit, and optionally re-start to correct.
One possible use of
.First
is to write a function
that returns the size of the current window (in a windowing environment),
and then uses these values to set
options()$height
and
options()$width
. A call to this function
could then be included in
.First
.
.First <- function() { cat("Hello, Welcome to S-PLUS\n") cat("Attaching splusfun directory\n") attach("/usr/joe/splusfun", 2) } .Last <- function(){ cat("Bye bye.\\n") } setenv S_FIRST 'cat("here is S_FIRST\n"); options(warn=2)'