#	SetDirectory - set the default directory
#
#	Usage:
#		SetDirectory directory
#
#	SetDirectory sets the default directory and adds the new default
#	directory to the Directory menu if it is not already present.
#
#
#	Copyright Apple Computer, Inc. 1987 - 1990
#	All rights reserved.

Set Echo 0
Set Exit 0
If {#} != 1  OR  "{1}" == ""
	Echo "### {0} - A directory must be specified." > Dev:StdErr
	Echo "# Usage - {0} directory" > Dev:StdErr
	Exit 1
Else
	Directory "{1}"
	If {Status} != 0
		Exit 2
	End
	Set directory `Directory`

	if !`Evaluate "{directory}" =~ /?«0,64»/`  # longer that 64 bytes?
		Unset ®1 ; Unset ®2
		(Evaluate "{directory}" =~ /(?«30»)®1≈(?«33»)®2/ ) ∑ dev:null
		Set menuname	"{®1}"'…'"{®2}"
	else
		Set menuname "{directory}"
	end

	AddMenu Directory "{menuname}" ∂
		'Directory "'"{directory}"'" > "{ShellDirectory}"MPW.Errors ≥ Dev:StdOut ∂
		  || Alert < "{ShellDirectory}"MPW.Errors'
End
