Workspace shared variables - Answer to exercise
Last updated at 5:40 pm UTC on 17 September 2019
There are different solutions, let's see first Morphic way, based on clicking object, then then the Workspace way, based on typing and evaluating code in the Workspace.
Solution 1. Morphic based
- clicking on the red halo –> you get the halos of the system window which wraps the workspace object
- choosing 'debug' -> 'explore'
- then click on 'model' –> the model
- you see an instance variable 'bindings'; it is a dictionary.
- that dictionary holds the variable 'myvar'
Solution 2. Through a script
The issue is about identifying the Workspace object containing the variables in which we are interested. For this to work the workspace needs a label as there might be other workspaces on the desktop.
Assuming the label (title) you gave to the workspace is 'myWorkspace' then the following script gives you the bindinges.
windows := Project current world submorphs select: [:sm | sm isKindOf: SystemWindow].
(windows detect: [:m | m label beginsWith: 'myWorkspace']) model inspectBindings
List the content of all workspaces of all projects in an image.