[Newbies] Global string search and replace in an image
smalltalktelevision at gmail.com
Tue Sep 11 12:03:35 UTC 2012
On 12-09-11 5:02 AM, Bert Freudenberg wrote:
> On 2012-09-11, at 01:43, Chris Cunnington <smalltalktelevision at gmail.com> wrote:
>> On 12-09-10 7:34 PM, Andy Burnett wrote:
>>> Is there a method - or other mechanism - that would let me find all instances of 'foo' and replace them with 'bar' within an image? I imagine there must be, but I can't find it.
>>> Beginners mailing list
>>> Beginners at lists.squeakfoundation.org
>> Try this:
>> OrderedCollection allInstances size
>> Print that. That's the number of instances of OC in the image. Now try
>> OrderedCollection allInstances
>> OrderedCollection allInstances first
>> And take a look at the living instances inside the image. That's how you find instances. Replacing them is kind of a different issue. I'd say two things about that. The first is you don't want to just replace instances in the image. You need to be more specific of the context of your instances. Are they in an OrderedCollection or an Array? If so, find that instance and change them inside.
>> The second thing is you wouldn't generally replace instances in the image. Just wait and they'll be eaten by the garbage collector.
>> So finding instances is not to hard. Use #allInstances. To replace them you need to look not so much at the whole image but the application those instances are in. Inside your app.
>> Oh, yea. You can use OrderedCollection allIstances and both explore and inspect. You can see inside the instances that way. (Explore and inspect are one of the main menus.)
>> Hope that helps,
> I thought Andy was talking about source code.
> Personally, if I have to rename a method, I search for all senders and fix them with copy&paste. Same for class renames, inst var renames, etc. There just are not that many occurrences, so fixing each one individually is quick, plus I get to verify that the change is indeed what I wanted.
> There is a tool to automate a lot of this called the Refactoring Browser, which many developers like, but I don't even have it in my image.
> - Bert -
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
On reading this again this morning, it clear he was talking about source
code. My mistake. Thanks for the correction.
More information about the Beginners