Environment Variables - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Information : envvar

Environment Variables

 

Description

Examples

Description

• 

An environment variable is similar to a global variable, except that any assignments made to it during the execution of a procedure are only in effect during the execution of that procedure, and any procedures called from it (to any depth) during the execution. When the procedure that assigned the environment variable exits, the assignment is undone, restoring any value the variable may have had previously.

• 

Maple has several built-in environment variables, with initial values as shown:

Name

Default Value

%, %%, %%%

The previous three results.

_ans

Equivalent to %

Digits

10

Normalizer

The built-in normal procedure.

NumericEventHandlers

[default,default,default,default,default,default]

Order

6

Rounding

nearest

Testzero

proc(x) evalb(Normalizer(x) = 0) end proc

UseHardwareFloats

deduced

`index/newtable`

unassigned

`mod`

The built-in modp procedure.

printlevel

1

• 

A variable with a name beginning with "_Env" defines a non-built-in environment variable. Such names are not active environment variables, in the sense that no space is reserved to save and restore their values, until they are assigned within a procedure.

• 

%, %%, and %%% are the results of the last, second last, and third last computation in the current environment. _ans is a synonym for %.

• 

Digits is the number of significant digits used for floating-point operations, and is set to 10 initially.

• 

Normalizer is set to `normal` initially, and is used by the kernel in series to normalize leading terms of divisors.

• 

NumericEventHandlers controls how numeric events such as numeric overflow are handled. See NumericEventHandler for details.

• 

Order represents the order of series calculations performed by Maple. It does not represent the order of the series output. Order is set to 6 initially.

• 

Rounding controls the rounding of floating-point results. See Rounding for more details.

• 

Testzero is initialized with proc(x) evalb(Normalizer(x) = 0) end proc, which is a relatively trivial test for zero. Testzero is used in the kernel by series, when it needs to determine whether a leading coefficient is zero for division. It is also used by many symbolic commands in the LinearAlgebra package, for example, to determine if a potential pivot is zero.

• 

UseHardwareFloats controls whether Maple's hardware or software floating-point computation environment is used to perform floating-point operations when hardware floating-point values are present in an expression. See UseHardwareFloats for more information.

• 

`index/newtable` is used as a validation function during the implicit creation of a new table via an assignment such as T[a] := b where T does not yet refer to a table.

• 

`mod` can be set to modp or mods, and controls which function is called to evaluate the mod operator. It is set to `modp` initially. See mod for more information.

• 

The setting of printlevel causes the display of the results of all statements executed up to the level indicated by printlevel. Initially, printlevel is set to 1. See printlevel for more information.

• 

The call anames('environment') returns a sequence of all active environment variables (as listed in the table above), and all global names beginning with _Env, whether or not they are active environment variables yet.

• 

The call anames('environment','active') returns a sequence of only active environment variables. Global names beginning with _Env are included only if they are active in the environment of some active procedure. Thus, this call will never return _Env variables unless invoked from within a procedure that has assigned to such a variable, or a procedure called directly or indirectly by such a procedure.

Examples

t := proc() Digits := Digits + 4; end proc:

During the execution of "t", Digits is increased by 4, and automatically reset on exit from "t".

Digits;

10

(1)

t();

14

(2)

Digits;

10

(3)

The following are examples of user-defined environment variables.

_EnvX := 1;

_EnvX1

(4)

_EnvY := 2;

_EnvY2

(5)

p := proc() _EnvY := 3 end proc:

p();

3

(6)

_EnvY;

2

(7)

The first call below returns the _Env names, but the second does not because they are not currently active.

anames('environment');

%,%%,%%%,Digits,Order,_EnvX,_EnvY,_ans,mod,Normalizer,Rounding,Testzero,index/newtable,printlevel,NumericEventHandlers,UseHardwareFloats

(8)

anames('environment','active');

%,%%,%%%,Digits,Order,_ans,mod,Normalizer,Rounding,Testzero,index/newtable,printlevel,NumericEventHandlers,UseHardwareFloats

(9)

If called from a procedure, the _Env names that have become active are also returned.

p := proc() _EnvY := 4; anames('environment','active') end proc:

p();

%,%%,%%%,Digits,Order,_EnvY,_ans,mod,Normalizer,Rounding,Testzero,index/newtable,printlevel,NumericEventHandlers,UseHardwareFloats

(10)

_EnvY;

2

(11)

 

See Also

Digits

ditto

mod

normal

NumericEventHandler

NumericEventHandlers

Order

printlevel

Rounding

series

Testzero

UseHardwareFloats