Next: , Previous: , Up: Variables   [Contents][Index]


6.1.2 Global Variables

A variable whose name starts with one of $ ! # is a global variable: It is available to the user in any context, at the main execution level, inside user-defined subroutines, and inside user-defined functions.

Some variables whose names start with a # are predefined read-only variables. The user cannot change their value. These variables contain constants of nature and the like. For instance, #pi returns the value of pi, the ratio between the circumference and the radius of a circle in a plane (see #pi).

The user can create more global variables whose names start with a #. These additional variables are global, their value can be changed, and they can be deleted again.

Variables whose names start with a ! are predefined global variables. The user cannot create such variables. These variables come in two flavors. One set is linked to one or more specific subroutines or functions and either govern some aspect of their behavior, or are assigned some value by the subroutine or function. This set of variables is only important if the corresponding subroutine or function is called, and their value can be modified by the user. For instance, !lastmax returns the maximum value that was found during the most recent call to any of the functions min, max, minloc, or maxloc (see !lastmax, min, max, minloc, maxloc), and !fftdp determines if FFTs are performed in single or double precision.

Variables in the second set are status functions, and they are not linked to any (other) subroutine or function. They generally require system I/O during their evaluation and generally yield a different value each time they are inspected. For example, !time returns a string containing the current time (see !time).

Variables whose names start with a $ are read-write global variables. No such variables are predefined, and the user can create, modify, and delete such variables just like any local variable.


Next: , Previous: , Up: Variables   [Contents][Index]