Creating a platform-dependent IC
In the final part of this example, you'll create platform-dependent leaf ICs. That is, you'll create two ICs that each contain platform-specific code in the form of platform-specific subapplications. In this part of the example, you'll use VA Smalltalk on both OS/2 and Windows, and thus will need access to development environments on both these types of machines.
To begin, modify your To-Do List example application to make it platform dependent. For example, add two subapplications, one for Windows and one for OS/2, and modify slightly the behavior of Thing instance method printOn:.
For more information on creating platform-specific subapplications, see Defining lineups for multiple platforms.
Now that you have an application with platform-specific code, create the ICs in the following order:
1. Windows leaf IC: winleaf.ic
2. OS/2 leaf IC: os2leaf.ic
Creating the Windows subapplication
1. In your Windows development image, load the applications IcTestModel and IcTestView.
2. Create a new edition of IcTestModel. Leave IcTestModel selected in the Organizer.
3. From the Organizer, select New from the Applications menu.
4. Enter IcTestModelWin for the application, and check the Subapplication of checkbox.
5. Select IcTestModelWin in the Organizer. From the Parts full menu, select New > Extension. For the class name to extend, enter Thing.
6. Open Thing in the Script Editor.
7. Select the method printOn:. From the Methods menu, select Move > To a new application. Select IcTestModelWin as the new application.
8. Change printOn: as follows:
printOn: aStream
aStream
nextPutAll: self name;
nextPutAll: ' thing on Windows'.
Your window should resemble the following. Notice in the status bar that printOn: is now defined in IcTestModelWin.
9. Make sure you save the changes to printOn:. Close the Script Editor for Thing. Version and release Thing, in both IcTestModel and IcTestModelWin. Version the subapplication IcTestModelWin, but do not yet version IcTestModel.
Adding a config expression for a Windows subapplication
Now instruct VA Smalltalk to load the IcTestModelWin subapplication only if the platform on which VA Smalltalk is running is Windows
1. From the Tools menu of the Transcript or the Organizer, select Application Editions. The Application Editions browser opens.
2. In the far left pane, below the button labeled Application Names, scroll down until you see IcTestModel, and select it. In the Editions and Versions pane, select your open edition.
3. In the Config. Expressions pane, select true; then display the pop-up menu. Select copy. In the prompter which appears, enter the following:
(System subsystemType: 'OS') = 'WIN32s'
You should execute this piece of code in a Workspace, display the return value, and verify that it evaluates to true.
4. In the Config. Expressions pane, select true again. In the Subapplications pane, select IcTestModelWin, display the pop-up menu, and select Delete.
5. Toggle the selection of the two items in the Config. Expressions pane, and notice the difference.
When an application loads, the configuration expressions are evaluated in the order they are listed, and evaluation stops when the first true expression is encountered. The expressions instruct VA Smalltalk to load IcTestModelWin if the host platform is Windows; otherwise load only IcTestModel with no subapplications. Next, add a subapplication and configuration expression for the OS/2 platform.
Creating the OS/2 subapplication
The steps you follow for OS/2 are virtually the same as above.
1. In your OS/2 development image, load the latest version of IcTestView and your open edition of IcTestModel.
2. Select IcTestModel in the Organizer.
3. From the Applications menu, select New.
4. Enter IcTestModelOS2 for the application, and check the Subapplication of checkbox.
5. Select IcTestModelOS2 in the Organizer. From the Parts menu, select New > Extension. For the class name to extend, enter Thing.
6. Open Thing in the Script Editor.
7. Add the method printOn:, as follows:
printOn: aStream
aStream
nextPutAll: self name;
nextPutAll: ' thing on OS/2'.
Your window should resemble the following. Notice in the status bar that printOn: is now defined in IcTestModelOS2.
8. Close the Script Editor for Thing. Version and release Thing in IcTestModelOS2. Version the subapplication IcTestModelOS2, but do not yet version IcTestModel.
Adding config expressions for OS/2 subapplications
9. From the Tools menu of the Transcript or the Organizer, select Application Editions. The Application Editions browser opens.
10. In the far left pane, below the button labeled Application Names, scroll down until you see IcTestModel, and select it. In the Editions and Versions pane, select your open edition.
11. In the Config. Expressions pane, select true; then display the pop-up menu. Select copy. In the prompter that appears, enter the following:
(System subsystemType: 'OS') = 'OS/2'
You should execute this piece of code in a Workspace, display the return value, and verify that it evaluates to true.
12. In the Config. Expressions pane, select true again. In the Subapplications pane, select IcTestModelOS2, display the pop-up menu, and select Delete.
13. Toggle the selection of the three items in the Config. Expressions pane, and notice the difference.
Last modified date: 02/15/2015