Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Set

Built-in

SYNTAX

Set [-e] [name [value]]

DESCRIPTION

The Set command defines or writes the value of MPW Shell variables. If you specify both name and value, Set defines the MPW Shell variable name as having the specified value. If you omit parameters, Set writes the value of MPW Shell variables to standard output.

Note
To make variable definitions available to enclosed scripts and programs, you must use the -e option or the Export command. •

INPUT

None

OUTPUT

None, unless you omit one or both parameters. If you omit value, Set writes the value of the variable name to standard output. If you omit both name and value, Set lists all variables and their values to standard output. In either case the output appears in the form of Set commands.

STATUS

Set can return the following status codes:

0

no error

1

syntax error

2

shell variable name does not exist

PARAMETERS

name

Names the MPW Shell variable.

value

Specifies the value to be assigned to name.

OPTIONS

-e

Exports the variable named in Set. Using -e allows you to set and export a variable with a single command. Note that if you use this option without specifying a variable name, Set outputs the list of MPW Shell variables indicating which variables have been exported and which have not.

EXAMPLES

The following command line sets the value of the {Status} variable to 0:

Set Status 0

To test that the variable definition was successful, the command line is executed with only the name parameter. This displays the name of the variable and its value in the form of the original Set command.

Set Status
Set Status 0

The following command line redefines the {CIncludes} variable to the {MPW}CFiles:CIncludes pathname.

Set CIncludes "{MPW}CFiles:CIncludes:"

Executing the command line below displays the new definition of CIncludes.

Set CIncludes

The next example redefines the {Commands} variable to include the {MPW}ShellScripts: directory.

Set Commands ∂
":,{MPW}Tools:,{MPW}Applications:,{MPW}ShellScripts:"

The following script lists all variables and their values, redirecting the output to the SavedVariables file. Since the output is written in the form of Set commands, you can execute the file later to restore the saved variable definitions. This technique is used in the Suspend and Resume scripts to save and restore variable definitions, as well as exports, command aliases, and menus.

Set > SavedVariables
  # … other commands
Execute SavedVariables

SEE ALSO

Export

Unexport

Unset

 
 


Last Updated July 2000