Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
FAQ: How do I prepare an image/executable to start up with my application
Last updated at 4:44 pm UTC on 16 January 2006
Q: I'm trying to use Squeak for creating a game that is supposed to automatically start when the user opens the image. How do I get Squeak to start running my startup code as soon as the image is opened?

A: There are a few different ways to do this:

1. You may be able to just save your image in an interesting configuration, i.e. with your application open. Keep in mind that when the image starts, it starts exactly where it left off.

2. As a variation, you can save your image like this (do all this code together in one DoIt):

        Smalltalk snapshot: true andQuit: false.
        self inform: 'Hello, world.'  "Replace this with your application-starting code"

3. You can use addToStartUpList: to register any object that understands startUp:; that object's startUp: method will be invoked every time the system starts. (Look in "snapshot and quit" under class SystemDictionary for details).

4. You can specify a script file when starting up Squeak, named on the command line. See Writing scripts for details.

5. . Open the World menu.
. Click on the "do..." item
. Choose "edit this list"
. Add a line saying:
Smalltalk saveSession. MyGameMorph openInWorld.
[Note this _needs_ to be a single line, so it might be easier to have a method on the class side of your game called "saveAndStartup" which you'd enter here].
. Accept the changes
. Click on the entry on the "do" menu.

Now your game comes up nicely. The reason why I (at times ;-) prefer that approach is that by simply saving the image _without_ using the above menu entry you get it back to the state where your game is not starting up.

See also FAQ: Squeak executables.