Initialization file
You can put assignments, procedures, packages, macros and anything else that is possible in Maple V into the Maple initialization file (`maple.ini` in DOS, `.mapleinit` in Linux) located in the subdirectory /lib (in Linux: home directory) .
This initialisation file is - if it exists - automatically loaded at startup or after a restart during a Maple session, so that you do not need to input various statements in order to prepare your Maple session every time again.
For example, if you want Maple to load short forms of the functions included in the plots package, assign Digits a changed default value, define a variable called 'h' with h=1e-8 and Euler's constant e (this is important in Maple V Release 4 and 5 where 'E' is no longer predefined), you have to type in:
`plots/init`:=proc() end: # Enter this line only if you are using Release 3
with(plots):
Digits:=20:
h:=1e-8:
alias(E=exp(1)):
(The character ` is the so-called back quote, i.e. ASCII control code 96.)
Also you can abridge Maple commands as follows for use in all worksheets:
macro(new=restart);
macro(ef=evalf);
In addition text can be displayed during interpretation of the initialization file:
print(`I am a Maple string.`);
or
`I am a Maple string.`;
Note: In Release 3 you may display text with the Maple command print or by entering a string followed by a semicolon. Also in R3, text generally is not displayed at the very first start of Maple V but after the command restart is entered during a Maple V session thereafter. The display command lprint cannot be used in Release 3 initialization files.
In Release 4 you may use the two commands print, lprint and strings to display text during startup. Contrary to Release 3, text is also printed when you start Maple V the first time (i.e. load the Maple program).
This is how a full Maple V4 initialization file could look like:
# maple.ini
# to be copied to maplev4\lib
# some macros:
# by typing "macros" in a Maple session you get all macros displayed
# that have been assigned.
macros :=
[bi = binomial,
eb = evalb,
ef = evalf,
inf = infinity,
lim = limit,
new = restart,
sc = 'scaling=constrained',
si = simplify,
sv = solve]:
for i to nops(macros) do
macro(macros[i])
od:
i := 'i': # unassign variable i
# -----------------------------------------------------------------------------
# Define Euler's constant E=2.7182818... like in R3
alias(E=exp(1)):
constants := constants, E: # append E to constants (like in R3)
# -----------------------------------------------------------------------------
# Set some defaults for package geometry and for function solve
_EnvHorizontalName := x: # name of ascissa
_EnvVerticalName := y: # name of ordinate
_EnvAllSolutions := true: # return a general solution with
# transcendental functions
# -----------------------------------------------------------------------------
# Extend libname so that Maple V can find user-defined packages and/or
# documentations
libname :=
`c:/maplev4/math`, # math package
`c:/maplev4/joe_riel`, # Joe Riel's Administering Maple V Release 4
`c:/maplev4/geom3d`, # geom3d for Release 4
`c:/maplev4/mv4ext`, # Patch for Invfunc
libname: # original default value of libname after
# startup
# -----------------------------------------------------------------------------
# load short forms for two packages (math and plots)
with(math):
with(plots, display):
# -----------------------------------------------------------------------------
# Set some options for plots functions (plot fonts now mostly like in R3)
plots[setoptions](
titlefont = [HELVETICA, BOLD, 12],
axesfont = [HELVETICA, 11],
labelfont = [HELVETICA, 11],
font = [HELVETICA, 11]):
# -----------------------------------------------------------------------------
# readlib-define some not readlib-defined Library functions,
# this avoids having to load the code of these functions with readlib
unprotect('evalr', 'iscont', 'discont', 'isolate', 'profile'):
evalr := 'readlib('evalr')':
iscont := 'readlib('iscont')':
discont := 'readlib('discont')':
isolate := 'readlib('isolate')':
profile := 'readlib('profile')':
protect('evalr', 'iscont', 'discont', 'isolate', 'profile'):
# -----------------------------------------------------------------------------
# some useful hacker functions
unprotect('pp'):
pp := proc(n::nonnegint):
if n < 3 then
interface(prettyprint=n)
else
ERROR(`Argument must be less than 3`)
fi
end:
protect('pp'):
unprotect('vp'):
vp := proc(n::nonnegint):
if n <= 3 then
interface(verboseproc=n)
else
ERROR(`Argument must be less than 4`)
fi
end:
protect('vp'):
unprotect('pl'):
pl := proc(n::nonnegint):
printlevel := n;
NULL
end:
protect('pl'):
You may even include read statements in the initialization file which reads Maple statements from other Maple text files (like the call command in NOVELL DOS 7's batch language). Also you can call other text files from the text file read by the initialization file.
Reference: Joe Riel has written a very useful and interesting documentation on Maple V' internals:
Administering Maple V .
back