#	Startup - MPW Shell Startup File
#
#	Copyright Apple Computer, Inc. 1985-1998
#	All Rights Reserved.

#	2009.09.22 (Tab:8)
#	Modified fo dis setup; 2007.11.02, 2007.11.24 - 2007.11.26


#	{Boot} - The boot disk.  (Predefined.)
		Export Boot

#	{SystemFolder} - The directory that contains System & Finder.  (Predefined.)
		Export SystemFolder

#	{ShellDirectory} - The directory that contains MPW Shell.  (Predefined.)
		Export ShellDirectory

#	{Active} - The active (topmost) window.  (Predefined.)
		Export Active

#	{Target} - The target (previously active) window.  (Predefined.)
		Export Target

#	{Worksheet} - The name of the Worksheet window.  (Predefined.)
		Export Worksheet

#	{Status} - The result of the last command executed.  (Predefined.)
		Export Status

#	{User} - Automatically defined to the name that appears in the Chooser.
		Export User

#	{MPW} - The volume or folder containing the Macintosh Programmer's Workshop.
#	  If you put the MPW Shell out on the desktop, redefine this variable
#	to be "{Boot}MPW:"

		Set MPW "{ShellDirectory}"
		Export MPW

#	{MPWVersion} - Version of MPW
		Export MPWVersion

#	Export internal variables  

#	{AllowCmdsOnlyInWorkSheet} -- allow enter key to execute commands only in worksheet
		Export AllowCmdsOnlyInWorkSheet

#	{AllowColorizing} -- turn text coloring on and off
		Export AllowColorizing

#	{AllowDraggingOut} -- allow drag and drop out of MPW windows
		Export AllowDraggingOut

#	{AllowMultipleUndo} -- allow multiple undo (a reasonable 50)
		Set AllowMultipleUndo 50
		Export AllowMultipleUndo

#	{CursorForDragging}	-- set the cursor to be displayed for drag and drop
		Export CursorForDragging

#	{ExtendWordSet}
		Export ExtendWordSet

#	{InhibitMarkCopy}
		Export InhibitMarkCopy

#	{NewKeyboardLayout}
#		Export NewKeyboardLayout

#	{ScreenUpdateDelay}
		Export ScreenUpdateDelay

#	{ToolSleepTime}
		Export ToolSleepTime

#	{Commands} - Directories to search for commands.  As of ETO 20 we have introduced
#	the concept of a user commands directory where you put your
#	personal commands.  We've also merged the tools and scripts
#	directories into a single directory called "Commands"
		Set Commands ":"
		If "`Exists -q "{MPW}User Commands:"`" 
			Set Commands "{Commands}","{MPW}User Commands:"
		End
		If "`Exists -q "{MPW}Commands:"`" 
			Set Commands "{Commands}","{MPW}Commands:"
		End
		If "`Exists -q "{MPW}Tools:"`" 
			Set Commands "{Commands}","{MPW}Tools:"
		End
		If "`Exists -q "{MPW}Scripts:"`" 
			Set Commands "{Commands}","{MPW}Scripts:"
		End
		Export Commands

# 	{PrefsFolder} - Directory to search for userstartup and quit scripts. (Predefined.)
#	  The shell looks in the {PrefsFolder} and then the {MPW} 
#	folder for startup and quit scripts.  {PrefsFolder} defaults to
#	{SystemFolder}Preferences:MPW.  You may change this here, 
#	or create an alias named MPW in the preferences folder to 
#	reference the folder where you keep your startup
#	scripts and worksheet.  
		Export PrefsFolder

#	{TempFolder}  - Directory for temporary items.   (Predefined.)
#	  The shell may create some temporary items here.
#	Defaults to {PrefsFolder}TempMPW.
		Export TempFolder

#	{SysTempFolder}  - Directory for temporary items.   (Predefined.)
#	  The shell may create some temporary items here.
#	Defaults to "{Boot}Temporary Items".
		Export SysTempFolder

#	As of ETO 20 we are moving towards having interfaces and
#	libraries optionally outside the MPW folder.
#	The new behavior is to first look up one level from
#	the mpw directory for the interfaces and libraries

		If "`Exists -q "{MPW}:Interfaces&Libraries:"`" 
			Set InterfacesandLibrariesLocation "{MPW}:Interfaces&Libraries:"
		Else If "`Exists -q "{MPW}Interfaces&Libraries:"`" 
			Set InterfacesandLibrariesLocation "{MPW}Interfaces&Libraries:"
		Else If "`Exists -q "Interfaces&Libraries:"`" 
			Set InterfacesandLibrariesLocation "Interfaces&Libraries:"
		Else
			Set InterfacesandLibrariesLocation "{MPW}"
		End

#	{AIncludes} - Directories to search for assembly language include files.
		Set AIncludes "{InterfacesandLibrariesLocation}Interfaces:AIncludes:"
		Export AIncludes

#	{Libraries} - Directory that contains shared libraries.
		Set Libraries "{InterfacesandLibrariesLocation}Libraries:Libraries:"
		Export Libraries

#	{CIncludes} - Directories to search for C include files.
		Set CIncludes "{InterfacesandLibrariesLocation}Interfaces:CIncludes:"
		Export CIncludes

#	{CLibraries} - Directory that contains C libraries.
		Set CLibraries "{InterfacesandLibrariesLocation}Libraries:CLibraries:"
		Export CLibraries

		If Not "`Exists -q "{InterfacesandLibrariesLocation}Libraries:CLibraries:"`"
			Set CLibraries "You have not installed the CLibraries for 68K development."
		End

#	{SCIncludes} - Directories to search for C include files.
		Set SCIncludes "{InterfacesandLibrariesLocation}Interfaces:CIncludes:"
		Export SCIncludes

#	{PPCCIncludes} - Directories to search for PowerPC include files.
		Set PPCCIncludes "{InterfacesandLibrariesLocation}Interfaces:CIncludes:"
		Export PPCCIncludes

#	{PPCLibraries} - Directory that contains PowerPC libraries. 
		Set PPCLibraries "{InterfacesandLibrariesLocation}"Libraries:PPCLibraries:
		Export PPCLibraries

		If Not "`Exists -q "{InterfacesandLibrariesLocation}Libraries:PPCLibraries:"`"
			Set PPCLibraries "You have not installed the CLibraries for PowerPC development."
		End

#	{PInterfaces} - Directories to search for Pascal interface files.
		Set PInterfaces "{InterfacesandLibrariesLocation}Interfaces:PInterfaces:"
		Export PInterfaces

#	{PLibraries} - Directory that contains Pascal libraries.
		Set PLibraries "{InterfacesandLibrariesLocation}Libraries:PLibraries:"
		Export PLibraries

		If Not "`Exists -q "{InterfacesandLibrariesLocation}Libraries:PLibraries:"`"
			Set PLibraries "You have not installed the Libraries for Pascal development."
		End

#	{RIncludes} - Directory that contains Rez include files.
		Set RIncludes "{InterfacesandLibrariesLocation}Interfaces:RIncludes:"
		Export RIncludes

#	{CFM68KLibraries} - Directory that contains CFM-68K static link libraries.
		Set CFM68KLibraries "{InterfacesandLibrariesLocation}Libraries:CFM68KLibraries:"
		Export CFM68KLibraries

		If Not "`Exists -q "{InterfacesandLibrariesLocation}Libraries:CFM68KLibraries:"`"
			Set CFM68KLibraries "You have not installed the Libraries for CFM 68K development."
		End

#	{SharedLibraries} - Directory that contains "fat" PEF-format import libraries.
		Set SharedLibraries "{InterfacesandLibrariesLocation}Libraries:SharedLibraries:"
		Export SharedLibraries

#	{CHeaders} - Directory that contains all "standard" precompiled headers.
		If "`Exists -q "{InterfacesandLibrariesLocation}Interfaces:HeadersPPC"`"
			Set CHeaders "{InterfacesandLibrariesLocation}Interfaces:HeadersPPC"
		Else If "`Exists -q "{MPW}Headers:"`"
			Set CHeaders "{MPW}Headers:"
		Else
			Set CHeaders "{MPW}"
		End
		Export CHeaders

		Unset InterfacesandLibrariesLocation

#	{CaseSensitive} - If non-zero, pattern matching is case sensitive.
		Set CaseSensitive 0
		Export CaseSensitive

#	{SearchBackward} - If non-zero, search will go backwards.
		Set SearchBackward 0
		Export SearchBackward

#	{SearchWrap} - If non-zero, search will wrap.
		Set SearchWrap 0
		Export SearchWrap

#	{SearchType} - Specifies the default searching type.  (0/literal,
#	1/word, 2/regular expression)
		Set SearchType 0
		Export SearchType

#	{Tab} - Default tab setting for new windows.
		Set Tab 8
		Export Tab

#	{Font} - Default Font for new windows.
		Set Font MPW
		Export Font

#	{FontSize} - Default font size for new windows.
		Set FontSize 9
		Export FontSize

#	{AutoIndent} - If non-zero, auto indentation will be the default for
#		new windows.
		Set AutoIndent 1
		Export AutoIndent

#	{WordSet} - Character set that defines words for searches and double-clicks.
		Set WordSet 'a-zA-Z_0-9'
		Export WordSet

#	{PrintOptions} - Options used by the Print Window and Print Selection menus.
		Set PrintOptions '-h'
		Export PrintOptions

#	{Exit} - If non-zero, command files terminate after the first error.
		Set Exit 1
		Export Exit

#	{Echo} - If non-zero, commands are echoed before execution.
		Set Echo 0
		Export Echo

#	{Test} - If non-zero, tools and applications are not executed.
		Set Test 0
		Export Test

#	{MarkAlphabetical} - If non-zero, marks will be listed alphabetically in the menu
#	by default.
		Set MarkAlphabetical 0
		Export MarkAlphabetical

#	Commando Support
		Export Windows
		Export Aliases
		Set Commando Commando
		Export Commando

#	Aliases
		Alias File Target

#	Clean up temporary files that are left over from a previous run.
		(Delete -i -y "{MPW}"MPW.Pipe- || Set Status 0) dev:null

#	The file UserStartup can be used to override definitions made in Startup,
#	or to define additional variables, exports, and aliases.  UserStartup may
#	also be used to define menu items, open windows, etc.  The file should be
#	located in the directory containing the MPW Shell, or in your preferences 
# 	folder.

#			If "{PrefsFolder}" && "`Exists -q "{PrefsFolder}UserStartup"`"
#				Execute "{PrefsFolder}UserStartup"
#			Else
#				Execute "{ShellDirectory}UserStartup"
#			End

#	As of ETO 20 we have decided that it made more sense to make all "Userstartup"
#	files sacred, i.e. they will never be replaced during an installation of MPW.
#   In fact the entire "Startup Folder" and "Quit Folder" are now off-limits
# 	for the MPW installer.  The  following used to appear in the UserStartup file.

#	Create the Project menu

if "`Exists -q "{PrefsFolder}"UserProjectMenu`"
	Execute "{PrefsFolder}"UserProjectMenu
else if "`Exists -q "{MPW}"UserProjectMenu`"
	Execute "{MPW}"UserProjectMenu
else
	ProjectMenu	# the default project menu
end

#	Create the Directory menu

#	The parameters to DirectoryMenu become the initial list of directories
#	in the Directory menu.  The parameters below specify each of the 
#	Examples directories, and the current directory.  Replace them with
#	your favorite directories.

if "`Exists -q "{PrefsFolder}"UserDirectoryMenu`"
	Execute "{PrefsFolder}"UserDirectoryMenu
else if "`Exists -q "{MPW}"UserDirectoryMenu`"
	Execute "{MPW}"UserDirectoryMenu
else
	DirectoryMenu `(Files -d -i "{MPW}"Examples: || Set Status 0)  Dev:Null` 
		`Directory`
end

#	Create the Build Menu

if "`Exists -q "{PrefsFolder}"UserBuildMenu`"
	Execute "{PrefsFolder}"UserBuildMenu
else if "`Exists -q "{MPW}"UserBuildMenu`"
	Execute "{MPW}"UserBuildMenu
else
	BuildMenu
end


# 	Add MPW Help to the Help menu.
#	Since this option is only supported in MPW Shell 3.3 and later, we
#	ignore any errors which may be reported by earlier shells.

	AddMenu -help 'MPW Help' 'InteractiveHelp'  Dev:Null || set Status 0

#	Since UserStartup is distributed with MPW, you may want to have other
#	startup files that will not be overwritten with a new release.
#	Other personalized startup files may be named UserStartup - such as 
#	"UserStartupJohn" or "UserStartupTom"  ( is option-8), and placed
#	in the MPW Preferences folder ({PrefsFolder}).  Alternately, you can
#	place additional startup items in the "Startup Items" folder located
#	in the directory containing the MPW Shell.  The items in the
#	"Startup Items" folder do not have any special naming conventions, and
#	will be executed in alphabetical order.  They can also be any type of
#	executable entity, such as scripts, tools, and/or applications.
#
#	The following executes such files found in either place.

		If "{PrefsFolder}"
			For __Startup__i in `(Files -t 'TEXT' -f -s "{PrefsFolder}"UserStartup || Set Status 0)  dev:null`
				Execute "{__Startup__i}"
			End
		End

		# Execute scripts, tools and applications.
		# Ignore everything else.
		For __Startup__i in `(Files -t 'TEXT' -f -s "{ShellDirectory}Startup Items:" || Set Status 0; Files -t 'APPL' -f -s "{ShellDirectory}Startup Items:" || Set Status 0; Files -t 'MPST' -f -s "{ShellDirectory}Startup Items:" || Set Status 0)  dev:null`
			Execute "{__Startup__i}"
		End

		# this method of running custom startup scripts is obsolete, and will be removed
		# in a future version of this script.  Please move your UserStartup scripts into
		# the new :Startup Items: folder.
		For __Startup__i in `(Files -t 'TEXT' -f -s "{ShellDirectory}"UserStartup || Set Status 0)  dev:null`
			Execute "{__Startup__i}"
		End

		Unset __Startup__i

# added; 2008.05.27 12:55 GMT, 2008.06.14 15:01 GMT
Set -e CSeriesLib "`Quote "{MPW}"MyCSeries:`"
#Set -e CSeriesIncludes "-i `Quote "{Libraries}":MyCSeries:include:`"
Set -e CSeriesIncludes "-i `Quote "{MPW}"MyCSeries:include:`"
