Today's Smalltalk Daily looks at a simple runtime scripting example. I've covered this topic before, but used the (more complex) BottomFeeder application as my example. Here, we take a simple "application" (a class with one method) and a simple subsystem to start it - along with the script to do the build. The script is reproduced below; if you would rather just watch the video, then just go here. I posted all of the code and steps for this yesterday if you would rather take this in textual post form. You can download the example code here.
"build a simple app"
"load all my needed parcels"
[#('SampleApp.pcl') do: [:each |
Parcel loadParcelFrom: each]]
on: MissingParcelSource
do: [:ex | ex resume: true].
"turn change log off, so that we can ship patches reasonably"
'ChangeSet.BroadcastChanges' asQualifiedReference
ifDefinedDo: [:flag |
'ChangeSet.BroadcastChanges' asQualifiedReference value: false].
"Set herald string"
ObjectMemory setHeraldString: 'This is an Example Application in VisualWorks'.
"reset parcel path"
Parcel searchPathModel value removeAll.
"set up runtime state"
DeploymentOptionsSystem current startInRuntime: true.
"set up runtime state"
UI.WindowManager noWindowBlock: [:windowManager | ].
stream := WriteStream on: String new.
stream nextPutAll: 'changeRequest'; cr; cr; tab.
stream nextPutAll: '^true'.
VisualLauncher compile: stream contents.
VisualLauncher allInstances do: [:each | each closeAndUnschedule. each release].
ObjectMemory garbageCollect.
Workbook allInstances do: [:each | each closeRequest].
(Delay forSeconds: 20) wait.
Parcel searchPathModel value: (List with: (PortableFilename named: '.')).
SourceFileManager default discardSources.
"Now save the image such that this file does not get looked for at startup"
[ObjectMemory permSaveAs: 'sample' thenQuit: false] fork.
[(Delay forSeconds: 45) wait.
RuntimeSystem isRuntime ifFalse: [ObjectMemory quit]] fork
Click on the viewer below to watch it now:
If you have trouble viewing that directly, you can click here to download the video directly
You can also watch it on YouTube:
Technorati Tags:
smalltalk, deployment, runtime, scripting