[Newbies] saving image automatically

Norbert Hartl norbert at hartl.name
Tue May 1 07:39:40 UTC 2007

On Mon, 2007-04-30 at 20:06 -0400, David Shaffer wrote:
> Norbert Hartl wrote:
> >
> >>     
> > I only have a saveAs selector but no saveAs: What squeak version are
> > you using?
> >   
> Oops.  I thought it was standard but it was one of my extensions 
> (modeled off similar code in SmalltalkImage):
> SmalltalkImage>>saveAs: newName
>     "Save the image  under the specified new name."
>     (SourceFiles at: 2) ifNotNil:
>         [self closeSourceFiles; "so copying the changes file will always 
> work"
>              saveChangesInFileNamed: (self fullNameForChangesNamed: 
> newName)].
>     self saveImageInFileNamed: (self fullNameForImageNamed: newName)

Do you use the name of the image you run as an argument to saveAs: ?
Using this approach does only work for me if the names are equal.
Otherwise running image A with the script and using saveAs: 'B' gives 
a working image B and an image A which quits immediately after start.

I thought the saveAs would change the images name. So I don't know how
image A can be affected by this script.

> >
> > Yes, me too. And an idea to automatically upgrade the image to the last
> > version found in Monticello ;)
> >
> >   
> I hacked something together based on the code in the Monticello base 
> mostly from MCFileRepositoryInspector>>refresh.  It wasn't too pretty.  
> I've asked for permission to post it from my employer...the more eyes on 
> it the better.
I played a little with code and got the following:

path := [MC repository]
repo := (MCDirectoryRepository new 
           directory: (FileDirectory on: path)
        (repo loadVersionFromFileNamed: (
           repo allFileNames first)

Works ok for me. Additionally I tried to do a poor window closer:

) do: [:class|
   (Smalltalk classNamed: class)
      allInstances do:
         [:each| each delete]].

Here I don't know how I can force a close of a window which has unsaved
changes. And I don't know how to switch of flaps permanently.

But I'm lucky. I can copy my image to something like deploy.image and

squeak deploy deploy.st 

to customize the image like I want it.


More information about the Beginners mailing list