Searching the image for text

Bert Freudenberg bert at freudenbergs.de
Sat Sep 22 14:20:42 UTC 2007


On Sep 22, 2007, at 15:52 , Jimmie Houchin wrote:

> What if I wanted to find an instance which had a variable which  
> contained a certain literal string? Can I do that?

Sure thing. All objects in the image are accessible and can be  
enumerated, and references traced. This is what inspectors and their  
friends are for. You need to get a reference to your String first:

	String allSubInstances select: [:s | s = 'Kernel']

Press Cmd-i to get an inspector on these strings, it's 11 in my  
image. Or use this to match substrings:

	String allSubInstances select: [:s | s includesSubString: 'Kernel']

Select one string, and in the menu select "objects pointing to this  
value". This will get you all objects referencing that string. From  
there you can continue to follow these references "backwards". A cool  
tool to do this is the pointer explorer from the same menu which lets  
you explore where objects are referenced from.

Btw, I once closed a valuable workspace with some long series of  
expressions in it. I used the #allSubInstances "trick" to get it back  
before the garbage collector could free it :)

> While I am at it.
>
> Can you find or browse the source code for things not created in a  
> browser?
>
> eg: Say someone more experienced than I wrote a small Class in a  
> Workspace. Possibly closed the workspace, possibly after creating  
> an instance of said Class. Would it show up in a browser? If not  
> how would you access such again?
>
> Or access anything created in a Workspace and the particular text  
> was deleted or the workspace closed?

There is no difference between classes created in a browser and those  
in a workspace. You have to understand that neither classes nor the  
browser is special - Everything Is An Object. The browser happens to  
be an object that manipulates class objects, just as you would do in  
a workspace.

- Bert -





More information about the Squeak-dev mailing list