Example: Examining the format of filed-out code
This example shows you what code filed out in the VAST chunk 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.
Ensuring that your system is set to the VAST chunk format
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 VAST chunk format. If it returns true, then change the setting to false by evaluating the following:
System genericFormat: false
Filing out a method
To file out the method addApplicationsToList:
1. Open a Class Browser on the class Chooser.
2. Select the category – all -- and then the private instance method addApplicationsToList.
3. From the Methods menu, select File Out.
File Out
4. In the displayed prompter, rename the file to add.mth in the entry field where you specify a file name. Then select OK (or Save). The system writes add.mth to the directory where your development image resides.
Viewing the method's format in a workspace
Now, look at add.mth in a Workspace:
1. Select Open from the File menu of any browser. Because you just filed out add.mth, the displayed prompter names it in the file list.
2. Select add.mth in the file list; then select OK (or Open).
A Workspace opens on the method, displaying the following:
Workspace on file-in code
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 chunk 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) chunk format looks like, complete the steps in Example: Renaming a class and changing its methods.
Last modified date: 04/06/2020