The MathXplorer/T distribution, once uncompressed, consists of four directories. Here are their contents:
lib |
two library files |
doc |
documentation in HTML format |
scripts |
Tcl scripts |
m-files |
various useful MathViews scripts |
MathXplorer/T consists of two Tcl packages: Mxt and MxtGr. Their functionality is delivered via
dynamic loading of the following library files found in the lib sub-directory:
| Windows | UNIX | provides Tcl Package |
requires Tcl Packages |
provides Tcl commands |
|---|---|---|---|---|
mxt.dll |
libmxt.so |
Mxt |
Tcl |
minterp |
mxtgr.dll |
libmxtgr.so |
MxtGr |
Tcl, Tk, Mxt |
graph |
These files should be placed in the standard system locations for dynamic
libraries. Alternatively, Windows users can augment their PATH environment variable to include the location
of these DLL's. Similarly, UNIX users can augment their LD_LIBRARY_PATH environment variable.
To load the MathXplorer/T packages, use Tcl's load command. Specify as its argument the path of
a library file containing the package. Should load complain with a file-not-found type of
message, check that:
PATH environment variable (LD_LIBRARY_PATH in UNIX) orIf you want the MathXplorer/T commands to be available on-demand, you have two options:
load command in Tcl's
start-up file. You can find out which file Tcl sources on start-up by inspecting the
tcl_rcFileName variable. pkg_mkIndex command to
generate indices of the MathXplorer/T packages. Use the indices in conjunction
with package require statements in Tcl code
that uses the packages. Note that package MxtGr depends
on package Mxt. However, package
Mxt need not be explicitly loaded
before MxtGr since MxtGr implicitly loads Mxt.
m-filesAs we mentioned in the introduction, the
MathXplorer/T package supports user-defined script files. These files have the
'.m' extension. For example, you can define
a function sigmag in the file
c:\m-files\sigmag.m containing the
following:
function [ mag ] = sigmag( x ) mag = abs(fft(x));
MathViews maintains a character array variable _MVPATH. It interprets this character array as a
separated list of directories which are to be search for files with the '.m' extension. When a MathViews interpreter is
created, it initializes the value of _MVPATH with the value of the environment
variable MVPATH, should it exist. At any
time, you can clear an interpreter's cache of loaded functions by invoking
(assuming an interpreter MV created on
Windows):
% MV eval clear functions % MV eval "_MVPATH='c:\\\\m-files;d:\\\\more-m-files\\\\foo'"
_MVPATH =
c:\m-files;d:\more-m-files\foo
(Admittedly obscene, the four back-slashes are needed under Windows to give
_MVPATH the value c:\m-files;d:\more-m-files\foo. The double-quotes
surrounding the argument to MV eval are
needed to prevent Tcl from interpreting the Windows path-list separator, the
semicolon, as a Tcl command separator. UNIX users don't have to suffer this
particular complication.). It is a good idea to set the MVPATH environment variable right before loading
the Mxt package, possibly in Tcl's start-up
script. This will guarantee that any MathViews interpreter created subsequently
will have an initialized value of its variable _MVPATH. Each MathViews interpreter can then
modify its value of _MVPATH.
Using wish, let's give it a try:
% package
names |
enumerate existing packages |
Tcl
Tk |
|
% load
mxt.dll |
load the Mxt package |
% package
names |
enumerate packages again |
Mxt Tcl
Tk |
minterp now available |
% set
env(MVPATH) c:\\my_dir |
set the MVPATH environment variable |
% minterp
create MV |
create an interpreter MV |
MV |
|
% MV eval
x=1:5 |
use MV to create a vector x |
x = |
|
% load
mxtgr.dll |
load the MxtGr package |
% package
names |
enumerate packages |
MxtGr Mxt Tcl
Tk |
graph now available |
% graph .g
-bg yellow |
create a widget .g |
.g |
|
% pack
.g |
display .g |
Last modified: Mon Nov 30 16:49:34 PST 1998