#	DirectoryMenu - create the Directory menu
#
#	Usage:
#		DirectoryMenu directory…
#
#	DirectoryMenu creates the menu shown below. The directory… parameter
#	specifies the initial list of directories that appear in the menu.
#
#		Directory
#
#		  Show Directory
#		  Set Directory…
#		  ----------------
#		  <directory…>
#
#	
#	Copyright Apple Computer, Inc. 1987 - 1990, 1992 - 1993
#	All rights reserved.

Set Echo 0
Set Exit 0
DeleteMenu Directory ≥ Dev:Null
AddMenu Directory 'Show Directory' ∂
	'(Echo "The default directory is ∂n"; Directory) | Alert -s'
AddMenu directory 'Set Directory…' ∂
	'set __OldExit__ "{exit}"; ∂
	unset exit; ∂
	Set __Directory__ "`GetFileName -d;  set __tmpStatus__ "{status}"`"; ∂
	if "{__tmpStatus__}" == 0; ∂
		SetDirectory {__Directory__} > "{ShellDirectory}"MPW.Errors ≥ Dev:StdOut; ∂
		if "{status}" != 0; ∂
			Alert < "{ShellDirectory}"MPW.Errors; ∂
		end; ∂
	end; ∂
	set exit "{__OldExit__}"; ∂
	unset __Directory__ __OldExit__ __tmpStatus__'
AddMenu Directory '(-' ''
For directory in {"Parameters"}
	Set directory "`Files -i -fr -q "{directory}" ≥ Dev:Null || Echo "{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
Exit 0
