Startup, etc. -  Startup, Suspend, Resume and Quit Examples


Copyright Apple Computer, Inc. 1987
All rights reserved.


This file contains a number of ideas for modifying the Startup,
Suspend, Resume, and Quit scripts.

Startup			-	executed when starting the MPW Shell
UserStartup		-	executed from Startup
Suspend			-  executed before running an application
Resume			-  executed on return from an application
Quit				-  executed before quitting the MPW Shell


Relocating the MPW Folder

	Normally MPW is installed in a folder called MPW on the boot disk.
	It's important for the MPW system to know the location of this folder,
	so that the tools, scripts, libraries, include files, etc. that make
	up MPW can be easily located.  You can change the name of the MPW
	folder, or move it to another disk or directory, without making
	any changes in the Startup file, as long as you keep the MPW Shell
	in the same folder.

	Variable {MPW}, defined in the Startup file, specifies the folder
	that contains the MPW system.  The following line in the Startup
	file specifies the default location:

		Set MPW "{ShellDirectory}"

	This defines the location of the MPW sytem to be in the directory
	containing the MPW Shell program.  If you keep your MPW Shell 
	on the desktop, you should define MPW to be the full path name of
	the directory containing the rest of the MPW system, for example:

		Set MPW "{Boot}MPW"


Saving Window Contents

	When you run an application or quit, the shell displays "Save Changes"
	dialogs for each modified window, to ask if you want to save the
	changes.  These dialogs can be avoided by explicitly saving any or
	all of the windows in the Suspend and Quit scripts.

	Add either of these lines at the end of Suspend and Quit:

		Save "{Worksheet}"	# Save the worksheet (the default)
		Save -a					# Save all windows



Multiple UserStartup Scripts

	You may have multiple user startup scripts.  Any script in the
	{MPW} folder named UserStartup•≈ will be executed from Startup
	after executing UserStartup.
	
	You can also set up your system to run a different UserStartup
	depending on the directory from which you start MPW.  To do this
	you will need to change one line of the Startup script, and put
	a UserStartup script in the different directories containing
	the files that you usually open from the Finder.  In the Startup
	script change:

			Execute "{ShellDirectory}UserStartup"
	to:
			Execute UserStartup
	
	When you start the MPW Shell by opening a document in the Finder, 
	the directory of that document is your default directory.  
	The UserStartup in that directory will then be executed rather
	than the default UserStartup.
			

State Saving

	The State script writes the current variable definitions, exports,
	aliases, and menu items, the default directory, and the list of open
	windows to standard output.  This state information is written in the
	form of commands that may be used later to restore the state.  The date
	is included in the first line of output.

	To see the State script, execute the following:

		Open "{MPW}"Examples:State

	Important:	In order to use the State script, you must move it to a
	directory in which the shell looks for commands.

		Duplicate "{MPW}"Examples:State "{MPW}"Scripts:

	To save the state information in a file, execute a command such as

		State > XYZ.Startup1

	The state can then be restored by executing the following:

		Unset
		Unexport
		Unalias
		DeleteMenu
		Close -a
		Execute XYZ.Startup1

	Moreover, the state can be restored after leaving the shell by
	double-clicking on the XYZ.Startup1 file.  (See the Double-clickable
	Scripts example above.)



Crashes in Applications

	When you crash in an application run from the MPW Shell (something
	that just might happen during debugging) you're forced to restart
	the shell, loosing your variables, aliases, open windows, etc.

	With a few changes to the Suspend and Resume scripts, and the double-
	clickable scripts changes above, you can double-click on the file
	written by Suspend to pick up where you left off after a crash in
	an application.

	Replace the Begin … End statement in Suspend with the following:

		State > "{ShellDirectory}"Suspend.Startup1

	Replace the Execute and Delete commands in Resume with the following:

		 Execute "{ShellDirectory}"Suspend.Startup1
		 Delete  "{ShellDirectory}"Suspend.Startup1

	These changes simply change the name of the file in which Suspend
	saves the state information, so that it ends with the .Startup1 suffix.
	This suffix indicates a double-clickable script that replaced Startup.
