Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
"Simple scripts" (e.g. block as the target)
Last updated at 6:11 am UTC on 12 October 2019
Simple scripting is done in a Workspace. See also Simpler Scripts.

You may write scripts for some kinds of objects, avoiding the need for Players, by setting blocks as the target for pluggable morphs. For example, let's say you want to load a remote piece of code from a project:

 | btn |
 btn := SimpleButtonMorph new.
 btn label: 'Load updates'.
 btn target: [HTTPSocket httpFileIn: 'http://example.com/squeak-updates.st'].
 btn actionSelector: #value.
 btn openInWorld.

You can have a lot of fun with this. In this way, you can create "scripts" behind buttons and other pluggable morphs that do just about anything. The blocks that are attached to the buttons will be saved and loaded with your project, just like any other object.

A simple script with a class as target

 | btn |
 btn := SimpleButtonMorph new.
 btn target: Project.
 btn label: 'up'.
 btn position: 20 @ (Display height - 40).
 btn actionSelector: #returnToParentProject.
 btn openInWorld.

A script where a block is used two times to create a morph: 500 calculi

Have a script which writes content to a stream and then use Open a Workspace with content.
Create a button for that script with by selecting it and choosing the menu 'button' for it.
The result is a button which creates a report.

Project current world goBack -- button for it

How to jump to a project (Smalltalk code)


See also A block as the target of a SimpleButtonMorph

Zip up a complete directory structure


Another idea is to construct a button which opens a window with a graphical display of the thumbnails of all projects.
This is explained in Recipe: Graphical display of all projects.

Find a keyword in a workspace

See also