@menu
* Introduction for Runtime Environment::  
* Interrupts::                  
* Functions and Variables for Runtime Environment::  
@end menu

@c -----------------------------------------------------------------------------
@node Introduction for Runtime Environment, Interrupts, Runtime Environment, Runtime Environment
@section Introduction for Runtime Environment
@c -----------------------------------------------------------------------------

@c THIS DISCUSSION OF maxima-init.mac REPLACES AN EARLIER WRITE-UP. !!!
@c HOWEVER IT SEEMS THAT THIS TEXT REALLY WANTS TO BE UNDER A DIFFERENT HEADING. !!!
@code{maxima-init.mac} is a file which is loaded automatically when Maxima
starts.  You can use @code{maxima-init.mac} to customize your Maxima
environment.  @code{maxima-init.mac}, if it exists, is typically placed in the
directory named by @code{maxima_userdir},
although it can be in any directory searched by the function @code{file_search}.

Here is an example @code{maxima-init.mac} file:

@example
setup_autoload ("specfun.mac", ultraspherical, assoc_legendre_p);
showtime:all;
@end example

In this example, @code{setup_autoload} tells Maxima to load the
specified file
(@code{specfun.mac}) if any of the functions (@code{ultraspherical},
@code{assoc_legendre_p}) are called but not yet defined.
Thus you needn't remember to load the file before calling the functions.

The statement @code{showtime: all} tells Maxima to set the @code{showtime}
variable.  The @code{maxima-init.mac} file can contain any other assignments or
other Maxima statements.

@opencatbox
@category{Session management}
@closecatbox

@c -----------------------------------------------------------------------------
@node Interrupts, Functions and Variables for Runtime Environment, Introduction for Runtime Environment, Runtime Environment
@section Interrupts
@c -----------------------------------------------------------------------------

The user can stop a time-consuming computation with the
^C (control-C) character.
The default action is to stop the computation
and print another user prompt.
In this case, it is not possible to restart a stopped computation.

If the Lisp variable @code{*debugger-hook*} is set to @code{nil}, by executing

@example
:lisp (setq *debugger-hook* nil)
@end example

@noindent
then upon receiving ^C, Maxima will enter the Lisp debugger,
and the user may use the debugger to inspect the Lisp environment.
The stopped computation can be restarted by entering
@code{continue} in the Lisp debugger.
The means of returning to Maxima from the Lisp debugger
(other than running the computation to completion)
is different for each version of Lisp.

On Unix systems, the character ^Z (control-Z) causes Maxima
to stop altogether, and control is returned to the shell prompt.
The @code{fg} command causes Maxima
to resume from the point at which it was stopped.

@opencatbox
@category{Console interaction}
@closecatbox

@c end concepts Runtime Environment

@c -----------------------------------------------------------------------------
@node Functions and Variables for Runtime Environment,  , Interrupts, Runtime Environment
@section Functions and Variables for Runtime Environment
@c -----------------------------------------------------------------------------

@c -----------------------------------------------------------------------------
@anchor{maxima_tempdir}
@defvr {System variable} maxima_tempdir

@code{maxima_tempdir} names the directory in which Maxima creates some temporary
files.  In particular, temporary files for plotting are created in
@code{maxima_tempdir}.

The initial value of @code{maxima_tempdir} is the user's home directory, if
Maxima can locate it; otherwise Maxima makes a guess about a suitable directory.

@code{maxima_tempdir} may be assigned a string which names a directory.

@opencatbox
@category{Global variables}
@closecatbox
@end defvr

@c -----------------------------------------------------------------------------
@anchor{maxima_userdir}
@defvr {System variable} maxima_userdir

@code{maxima_userdir} names a directory which Maxima searches to find Maxima and
Lisp files.  (Maxima searches some other directories as well;
@code{file_search_maxima} and @code{file_search_lisp} are the complete lists.)

The initial value of @code{maxima_userdir} is a subdirectory of the user's home
directory, if Maxima can locate it; otherwise Maxima makes a guess about a
suitable directory.

@code{maxima_userdir} may be assigned a string which names a directory.
However, assigning to @code{maxima_userdir} does not automatically change
@code{file_search_maxima} and @code{file_search_lisp};
those variables must be changed separately.

@opencatbox
@category{Global variables}
@closecatbox
@end defvr

@c -----------------------------------------------------------------------------
@anchor{room}
@deffn  {Function} room ()
@deffnx {Function} room (true)
@deffnx {Function} room (false)

Prints out a description of the state of storage and
stack management in Maxima.  @code{room} calls the Lisp function of 
the same name.

@itemize @bullet
@item
@code{room ()} prints out a moderate description.
@item
@code{room (true)} prints out a verbose description.
@item
@code{room (false)} prints out a terse description.
@end itemize

@opencatbox
@category{Debugging}
@closecatbox
@end deffn

@c -----------------------------------------------------------------------------
@anchor{sstatus}
@deffn {Function} sstatus (@var{keyword}, @var{item})

When @var{keyword} is the symbol @code{feature}, @var{item} is put on the list
of system features.  After @code{sstatus (keyword, item)} is executed,
@code{status (feature, item)} returns @code{true}.  If @var{keyword} is the
symbol @code{nofeature}, @var{item} is deleted from the list of system features.
This can be useful for package writers, to keep track of what features they have
loaded in.

See also @code{status}.

@opencatbox
@category{Programming}
@closecatbox
@end deffn

@c -----------------------------------------------------------------------------
@anchor{status}
@deffn  {Function} status (@code{feature})
@deffnx {Function} status (@code{feature}, @var{item})

Returns information about the presence or absence of certain system-dependent 
features.

@itemize @bullet
@item
@code{status (feature)} returns a list of system features. These include Lisp 
version, operating system type, etc. The list may vary from one Lisp type to 
another.

@item 
@code{status (feature, item)} returns @code{true} if @var{item} is on the
list of items returned by @code{status (feature)} and @code{false} otherwise.
@code{status} quotes the argument @var{item}. The quote-quote operator 
@code{'@w{}'} defeats quotation. A feature whose name contains a special 
character, such as a hyphen, must be given as a string argument. For example,
@code{status (feature, "ansi-cl")}.
@end itemize

See also @code{sstatus}.

The variable @code{features} contains a list of features which apply to 
mathematical expressions. See @code{features} and @code{featurep} for more 
information.

@opencatbox
@category{Programming}
@closecatbox
@end deffn

@c NEEDS CLARIFICATION

@c -----------------------------------------------------------------------------
@anchor{system}
@deffn {Function} system (@var{command})

Executes @var{command} as a separate process.  The command is passed to the
default shell for execution.  @code{system} is not supported by all operating
systems, but generally exists in Unix and Unix-like environments.

Supposing @code{_hist.out} is a list of frequencies which you wish to plot as a
bar graph using @code{xgraph}.

@example
(%i1) (with_stdout("_hist.out",
           for i:1 thru length(hist) do (
             print(i,hist[i]))),
       system("xgraph -bar -brw .7 -nl < _hist.out"));
@end example

In order to make the plot be done in the background (returning control to
Maxima) and remove the temporary file after it is done do:

@example
system("(xgraph -bar -brw .7 -nl < _hist.out;  rm -f _hist.out)&")
@end example
@end deffn

@c -----------------------------------------------------------------------------
@anchor{time}
@deffn {Function} time (%o1, %o2, %o3, @dots{})

Returns a list of the times, in seconds, taken to compute the output lines
@code{%o1}, @code{%o2}, @code{%o3}, @dots{} The time returned is Maxima's
estimate of the internal computation time, not the elapsed time.  @code{time}
can only be applied to output line variables; for any other variables,
@code{time} returns @code{unknown}.

Set @code{showtime: true} to make Maxima print out the computation time 
and elapsed time with each output line.

@opencatbox
@category{Debugging}
@closecatbox
@end deffn

@c -----------------------------------------------------------------------------
@anchor{timedate}
@deffn  {Function} timedate ()
@deffnx {Function} timedate (@var{T})

@code{timedate()} with no argument
returns a string representing the current time and date.
The string has the format @code{YYYY-MM-DD HH:MM:SS[+|-]ZZ:ZZ},
where the fields are year, month, day, hours, minutes, seconds, and time zone
offset in hours and minutes.

@code{timedate(@var{T})} returns the time @var{T}
as a string with the format @code{YYYY-MM-DD HH:MM:SS[+|-]ZZ:ZZ}.
@var{T} is interpreted as the number of seconds since midnight, January 1, 1900,
as returned by @code{absolute_real_time}.

Example:

@code{timedate} with no argument returns a string representing the current time and date.

@c ===beg===
@c d : timedate ();
@c print ("timedate reports current time", d) $
@c ===end===
@example
(%i1) d : timedate ();
(%o1)                      2010-06-08 04:08:09+01:00
(%i2) print ("timedate reports current time", d) $
timedate reports current time 2010-06-08 04:08:09+01:00
@end example

@code{timedate} with an argument returns a string representing the argument.

@c ===beg===
@c timedate (0);
@c timedate (absolute_real_time () - 7*24*3600);
@c ===end===
@example
(%i1) timedate (0);
(%o1)                      1900-01-01 01:00:00+01:00
(%i2) timedate (absolute_real_time () - 7*24*3600);
(%o2)                      2010-06-01 04:19:51+01:00
@end example

@opencatbox
@category{Time and date functions}
@closecatbox
@end deffn

@c -----------------------------------------------------------------------------
@anchor{absolute_real_time}
@deffn {Function} absolute_real_time ()

Returns the number of seconds since midnight, January 1, 1900 UTC.
The return value is an integer.

See also @code{elapsed_real_time} and @code{elapsed_run_time}.

Example:

@c ===beg===
@c absolute_real_time ();
@c 1900 + absolute_real_time () / (365.25 * 24 * 3600);
@c ===end===
@example
(%i1) absolute_real_time ();
(%o1)                      3385045277
(%i2) 1900 + absolute_real_time () / (365.25 * 24 * 3600);
(%o2)                   2007.265612087104
@end example

@opencatbox
@category{Time and date functions}
@closecatbox
@end deffn

@c -----------------------------------------------------------------------------
@anchor{elapsed_real_time}
@deffn {Function} elapsed_real_time ()

Returns the number of seconds (including fractions of a second)
since Maxima was most recently started or restarted.
The return value is a floating-point number.

See also @code{absolute_real_time} and @code{elapsed_run_time}.

Example:

@c ===beg===
@c elapsed_real_time ();
@c expand ((a + b)^500)$
@c elapsed_real_time ();
@c ===end===
@example
(%i1) elapsed_real_time ();
(%o1)                       2.559324
(%i2) expand ((a + b)^500)$
(%i3) elapsed_real_time ();
(%o3)                       7.552087
@end example

@opencatbox
@category{Time and date functions}
@closecatbox
@end deffn

@c -----------------------------------------------------------------------------
@anchor{elapsed_run_time}
@deffn {Function} elapsed_run_time ()

Returns an estimate of the number of seconds (including fractions of a second)
which Maxima has spent in computations since Maxima was most recently started
or restarted.  The return value is a floating-point number.

See also @code{absolute_real_time} and @code{elapsed_real_time}.

Example:

@c ===beg===
@c elapsed_run_time ();
@c expand ((a + b)^500)$
@c elapsed_run_time ();
@c ===end===
@example
(%i1) elapsed_run_time ();
(%o1)                         0.04
(%i2) expand ((a + b)^500)$
(%i3) elapsed_run_time ();
(%o3)                         1.26
@end example

@opencatbox
@category{Time and date functions}
@closecatbox
@end deffn

