Next: , Previous: Persistent Variables, Up: Variables


9.3 Status of Variables

— Command: clear [-x] pattern ...

Delete the names matching the given patterns from the symbol table. The pattern may contain the following special characters:

?
Match any single character.
*
Match zero or more characters.
[ list ]
Match the list of characters specified by list. If the first character is ! or ^, match all characters except those specified by list. For example, the pattern `[a-zA-Z]' will match all lower and upper case alphabetic characters.

For example, the command

          clear foo b*r
     

clears the name foo and all names that begin with the letter b and end with the letter r.

If clear is called without any arguments, all user-defined variables (local and global) are cleared from the symbol table. If clear is called with at least one argument, only the visible names matching the arguments are cleared. For example, suppose you have defined a function foo, and then hidden it by performing the assignment foo = 2. Executing the command clear foo once will clear the variable definition and restore the definition of foo as a function. Executing clear foo a second time will clear the function definition.

With -x, clear the variables that don't match the patterns.

This command may not be used within a function body.

— Command: who options pattern ...
— Command: whos options pattern ...

List currently defined symbols matching the given patterns. The following are valid options. They may be shortened to one character but may not be combined.

-all
List all currently defined symbols.
-builtins
List built-in variables and functions. This includes all currently compiled function files, but does not include all function files that are in the LOADPATH.
-functions
List user-defined functions.
-long
Print a long listing including the type and dimensions of any symbols. The symbols in the first column of output indicate whether it is possible to redefine the symbol, and whether it is possible for it to be cleared.
-variables
List user-defined variables.

Valid patterns are the same as described for the clear command above. If no patterns are supplied, all symbols from the given category are listed. By default, only user defined functions and variables visible in the local scope are displayed.

The command whos is equivalent to who -long.

— Command: whos options pattern ...

See who.

— Built-in Variable: whos_line_format

This string decides in what order attributtes of variables are to be printed. The following commands are used:

%b
Prints number of bytes occupied by variables.
%e
Prints elements held by variables.
%n
Prints variable names.
%p
Prints protection attributtes of variables.
%s
Prints dimensions of variables.
%t
Prints type names of variables.

Every command may also have a modifier:

l
Left alignment.
r
Right alignment (this is the default).
c
Centered (may only be applied to command %s).

A command is composed like this: %[modifier]<command>[:size_of_parameter[:center-specific[:print_dims[:balance]]]];

Command and modifier is already explained. Size_of_parameter tells how many columns the parameter will need for printing. print_dims tells how many dimensions to print. If number of dimensions exceeds print_dims, dimensions will be printed like x-D. center-specific and print_dims may only be applied to command %s. A negative value for print_dims will cause Octave to print all dimensions whatsoever. balance specifies the offset for printing of the dimensions string.

Default format is " %p:4; %ln:6; %cs:16:6:8:1; %rb:12; %lt:-1;\n".

— Built-in Function: exist (name, type)

Return 1 if the name exists as a variable, 2 if the name (after appending `.m') is a function file in Octave's LOADPATH, 3 if the name is a `.oct' file in Octave's LOADPATH, 5 if the name is a built-in function, 7 if the name is a directory, 101 if the name is a built-in variable, 102 if the name is a built-in constant, or 103 if the name is a function not associated with a file (entered on the command line).

Otherwise, return 0.

This function also returns 2 if a regular file called name exists in Octave's LOADPATH. If you want information about other types of files, you should use some combination of the functions file_in_path and stat instead.

If the optional argument type is supplied, check only for symbols of the specified type. Valid types are

`"var"'
Check only for variables.
`"builtin"'
Check only for built-in functions.
`"file"'
Check only for files.
`"dir"'
Check only for directories.

— Built-in Function: document (symbol, text)

Set the documentation string for symbol to text.

— Command: type options name ...

Display the definition of each name that refers to a function.

Normally also displays if each name is user-defined or builtin; the -q option suppresses this behaviour.

Currently, Octave can only display functions that can be compiled cleanly, because it uses its internal representation of the function to recreate the program text.

Comments are not displayed because Octave's parser currently discards them as it converts the text of a function file to its internal representation. This problem may be fixed in a future release.

— Command: which name ...

Display the type of each name. If name is defined from a function file, the full name of the file is also displayed.