This example shows you what code filed out in the IBM Smalltalk format looks like. Though you can file out any component loaded in your image, this example files out the method addApplicationsToList, which you created in Example: Adding methods to the defined class Chooser.
To file out addApplicationsToList, complete the following steps.
Begin by checking the setting for the file-out format. To do this, display the expression System genericFormat in a Transcript or Workspace window. (See Example: Evaluating an expression to change a setting.)
If the system returns false, then it is set to the IBM Smalltalk format. If it returns true, then change the setting to false by evaluating the following:
System genericFormat: false
To file out the method addApplicationsToList:
Now, look at add.mth in a Workspace:
A Workspace opens on the method, displaying the following:
The first line of text, ! Chooser privateMethods !, indicates that this is a private method for the class Chooser. When you file in code, the system executes the text between the two exclamation points. This sends the message privateMethods to Chooser. All classes support privateMethods. It enables the system to receive the next set of text as private methods for that class. If you had filed out code in the generic format, the line of text would have read ! Chooser methods !; thus, it would not have indicated the method's structure.
The system interprets the text up to the next exclamation point as a method. Each set of text delimited by an exclamation point is referred to as a chunk. The system continues to read the next set of chunks as methods for the designated class until it finds either the end of the file or an empty chunk. An empty chunk contains only a space character. The empty chunk informs the system that there are no more private methods.
Because of this chunking of code, you can file out several different types of components into one file. For each type of component, the first chunk commonly specifies the name of the containing component as well as the type and structure of the components to follow in the file. The components following that chunk each have an exclamation point as a divider. The end of the file has two exclamation points.
To see what the other (generic) format looks like, complete the steps in Example: Renaming a class and changing its methods.