# 2.09: Saving and Sharing Smalltalk Code


Now that you have the Quinto game working, you probably want to save it somewhere so that you can share it with your friends. Of course, you can save your whole Squeak image, and show off your first program by running it, but your friends probably have their own code in their images, and don’t want to give that up to use your image. What you need is a way of getting source code out of your Squeak image so that other programmers can bring it into theirs.

The simplest way of doing this is by filing out the code. The yellow-button menu in the System Categories pane will give you the option to file out the whole of category SBE-Quinto. The resulting file is more or less human readable, but is really intended for computers, not humans. You can email this file to your friends, and they can file it into their own Squeak images using the file list browser.

$$\bigstar$$ Yellow-click on the SBE-Quinto category and fileOut the contents.

You should now find a file called “SBE-Quinto.st” in the same folder on disk where your image is saved. Have a look at this file with a text editor.

$$\bigstar$$ Open a fresh Squeak image and use the File List tool to file in the SBE-Quinto.st fileout. Verify that the game now works in the new image.

## Monticello Packages

Although fileouts are a convenient way of making a snapshot of the code you have written, they are decidedly “old school”. Just as most open-source projects find it much more convenient to maintain their code in a repository using CVS1 or Subversion2, so Squeak programmers find it more convenient to manage their code using Monticello packages. These packages are represented as files with names ending in .mcz; they are actually zip-compressed bundles that contain the complete code of your package.

Using the Monticello package browser, you can save packages to repositories on various types of server, including FTP and HTTP servers; you can also just write the packages to a repository in a local file system directory. A copy of your package is also always cached on your local hard-disk in the package-cache folder. Monticello lets you save multiple versions of your program, merge versions, go back to an old version, and browse the differ- ences between versions. In fact, Monticello is a distributed revision control system; this means it allows developers to save their work on different places, not on a single repository as it is the case with CVS or Subversion.

You can also send a .mcz file by email. The recipient will have to place it in her package-cache folder; she will then be able to use Monticello to browse and load it.

$$\bigstar$$ Open the Monticello browser by selecting World ⊳ open. . . ⊳ Monticello browser.

In the right-hand pane of the browser (see Figure $$\PageIndex{2}$$) is a list of Monticello repositories, which will include all of the repositories from which code has been loaded into the image that you are using.

At the top of the list in the Monticello browser is a repository in a local directory called the package cache, which caches copies of the packages that you have loaded or published over the network. This local cache is really handy because it lets you keep your own local history; it also allows you to work in places where you do not have internet access, or where access is slow enough that you do not want to save to a remote repository very frequently.

## Saving and Loading Code with Monticello

On the left-hand side of the Monticello browser is a list of packages that have a version loaded into the image; packages that have been modified since they were loaded are marked with an asterisk. (These are sometimes referred to as dirty packages.) If you select a package, the list of repositories is restricted to just those repositories that contain a copy of the selected package.

What is a package? For now, you can think of a package as a group of class and method categories that share the same prefix. Since we put all of the code for the Quinto game into the class category called SBE-Quinto, we can refer to it as the SBE–Quinto package.

$$\bigstar$$ Add the SBE–Quinto package to your Monticello browser using the +Package button and type SBE–Quinto.

## SqueakSource: a SourceForge for Squeak

We think that the best way to save your code and share it is to create an account for your project on a SqueakSource server. SqueakSource is like SourceForge3: it is a web front-end to a HTTP Monticello server that lets you manage your projects. There is a public SqueakSource server at http://www.squeaksource.com, and a copy of the code related to this book is stored there at http://www.squeaksource.com/SqueakByExample.html. You can look at this project with a web browser, but it’s a lot more productive to do so from inside Squeak, using the Monticello browser, which lets you manage your packages.

$$\bigstar$$ Open a web browser to www.squeaksource.com. Create an account for yourself and then create (i.e., “register”) a project for the Quinto game.

SqueakSource will show you the information that you should use when adding a repository using the Monticello browser.

Once your project has been created on SqueakSource, you have to tell your Squeak system to use it.

$$\bigstar$$ With the SBE–Quinto package selected, click the +Repository button in the Monticello browser.

You will see a list of the different types of Repository that are available; to add a SqueakSource repository select HTTP. You will be presented with a dialog in which you can provide the necessary information about the server. You should copy the presented template to identify your SqueakSource project, paste it into Monticello and supply your initials and password:

MCHttpRepository
location: 'http://www.squeaksource.com/YourProject'
user: 'yourInitials'


If you provide empty initials and password strings, you can still load the project, but you will not be able to update it:

MCHttpRepository
location: 'http://www.squeaksource.com/YourProject'
user: ''


Once you have accepted this template, your new repository should be listed on the right-hand side of the Monticello browser.

$$\bigstar$$ Click on the Save button to save a first version of your Quinto game on SqueakSource.

To load a package into your image, you must first select a particular version. You can do this in the repository browser, which you can open using the Open button or the yellow-button menu. Once you have selected a version, you can load it onto your image.

$$\bigstar$$ Open the SBE–Quinto repository you have just saved.

Monticello has many more capabilities, which will be discussed in depth in Chapter 6. You can also look at the on-line documentation for Monticello at http://www.wiresong.ca/Monticello/.

1. www.nongnu.org/cvs
2. subversion.tigris.org

3. www.sourceforge.net

This page titled 2.09: Saving and Sharing Smalltalk Code is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Andrew P. Black, Stéphane Ducasse, Oscar Nierstrasz, Damien Pollet via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.