[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 32. Runtime Environment

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 32.1 Introduction for Runtime Environment

`maxima-init.mac` is a file which is loaded automatically when Maxima starts. You can use `maxima-init.mac` to customize your Maxima environment. `maxima-init.mac`, if it exists, is typically placed in the directory named by `maxima_userdir`, although it can be in any directory searched by the function `file_search`.

Here is an example `maxima-init.mac` file:

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

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

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

Categories: Session management

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 32.2 Interrupts

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 `*debugger-hook*` is set to `nil`, by executing

    :lisp (setq *debugger-hook* nil)

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 `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 `fg` command causes Maxima to resume from the point at which it was stopped.

Categories: Console interaction

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 32.3 Functions and Variables for Runtime Environment

System variable: maxima_tempdir

  `maxima_tempdir` names the directory in which Maxima creates some temporary files. In particular, temporary files for plotting are created in `maxima_tempdir`.

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

  `maxima_tempdir` may be assigned a string which names a directory.

  Categories: Global variables

System variable: maxima_userdir

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

  The initial value of `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.

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

  Categories: Global variables

Function: room ()
Function: room (true)
Function: room (false)

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

  - `room ()` prints out a moderate description.
  - `room (true)` prints out a verbose description.
  - `room (false)` prints out a terse description.

  Categories: Debugging

Function: sstatus (keyword, item)

  When keyword is the symbol `feature`, item is put on the list of system features. After `sstatus (keyword, item)` is executed, `status (feature, item)` returns `true`. If keyword is the symbol `nofeature`, 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 `status`.

  Categories: Programming

Function: status (`feature`)
Function: status (`feature`, item)

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

  - `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.
  - `status (feature, item)` returns `true` if item is on the list of items returned by `status (feature)` and `false` otherwise. `status` quotes the argument item. The quote-quote operator `''` defeats quotation. A feature whose name contains a special character, such as a hyphen, must be given as a string argument. For example, `status (feature, "ansi-cl")`.

  See also `sstatus`.

  The variable `features` contains a list of features which apply to mathematical expressions. See `features` and `featurep` for more information.

  Categories: Programming

Function: system (command)

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

  Supposing `_hist.out` is a list of frequencies which you wish to plot as a bar graph using `xgraph`.

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

  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:

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

Function: time (%o1, %o2, %o3, …)

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

  Set `showtime: true` to make Maxima print out the computation time and elapsed time with each output line.

  Categories: Debugging

Function: timedate ()
Function: timedate (T)

  `timedate()` with no argument returns a string representing the current time and date. The string has the format `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.

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

  Example:

  `timedate` with no argument returns a string representing the current time and date.

      (%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

  `timedate` with an argument returns a string representing the argument.

      (%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

  Categories: Time and date functions

Function: absolute_real_time ()

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

  See also `elapsed_real_time` and `elapsed_run_time`.

  Example:

      (%i1) absolute_real_time ();
      (%o1)                      3385045277
      (%i2) 1900 + absolute_real_time () / (365.25 * 24 * 3600);
      (%o2)                   2007.265612087104

  Categories: Time and date functions

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 `absolute_real_time` and `elapsed_run_time`.

  Example:

      (%i1) elapsed_real_time ();
      (%o1)                       2.559324
      (%i2) expand ((a + b)^500)$
      (%i3) elapsed_real_time ();
      (%o3)                       7.552087

  Categories: Time and date functions

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 `absolute_real_time` and `elapsed_real_time`.

  Example:

      (%i1) elapsed_run_time ();
      (%o1)                         0.04
      (%i2) expand ((a + b)^500)$
      (%i3) elapsed_run_time ();
      (%o3)                         1.26

  Categories: Time and date functions

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Charlie & on April, 26 2013 using texi2html 1.76.