Hi all,
I am using the Scratch source code for some development projects and for this try to port parts of Scratch to a more recent Squeak Image (e.g. 3.10).
Right now I am stuck with the ScratchSkin class variable in the ScratchFrameMorph class. In the new image ScratchSkin doesn't seem to be initialized.
How I debugged it so far:
- putting a "self halt." right at the beginning of ScratchFrameMorph class>>new (just before "ScratchSkin ifNil: ...")
- do it: "ScratchFrameMorph new openInWorld."
Looking at the Debugger:
- in the original image ScratchSkin is set with all the forms in it
- in the new image ScratchSkin is nil
Does anyone know how or where ScratchSkin is initialized. My understanding is that "new" is the first message being evaluated. So I am really stuck here...
I hope someone can give me some hints or pointers.
Thanks,
matsch
P.S.: I am not only new to Scratch development, but also to Smalltalk/Squeak.
Offline
Hi matsch,
the #new method only initializes a new instance of a class in Smalltalk. Actually the code for #new (inherited from class Object) in Squeak is:
^self basicNew initialize
(that's where the #initialize message comes from: #basicNew is the primitive creating the new instance which is afterwards receiving the #initialize message).
A class itself can be initialized in many ways, usually there's an #initialize method on the class side to look for, which is not automatically sent during runtime, but only once when the class is created or filed in. You can also browse for all class var refs/defs to find out how they are accessed.
In case of the ScratchSkin what you need to do is file out the ScratchSkin (not the code, but the actual object - it's a dictionary) from the source code image and import it into your target image. There are several ways to do this, I'm sure you'll find one that works out for you
(hint: it might be best to file out all images as .gifs into a separate folder, each named the same as its key, rather than creating a single binary).
BTW, I'd like to know what it is exactly in Squeak 3.10 that interests you with Scratch? Personally I'm a huge fan of the Scratch.image, because it is so much smaller, more direct, and easier to get around in. Plus, morphic is a lot less bloated and actually useable...
P.S.: When you're setting a breakpoint you can send #halt to any object, not only to "self", so just typing "1 halt" is easier and shorter, lol!
Offline
Hi Jens,
thanks for your very quick reply yesterday!
It wasn't as easy (for me) as you indicated. ;-)
But I now managed to import the .GIFs on every program start into the image. I still need to figure out how I can integrate them with the code and not only the current image (I'm working distributed across several images/PCs using Monticello).
Concerning the image: I agree the original Scratch image being more lean and slim. We opted for a newer image because we needed several additional functions (soap, monticello, image conversion), which may or may not be available for older images but are probably not up-to-date. I agree on the bloated part though. While it was (and is still) a hassle to port Scratch, we only make use of very little of it.
Thanks,
matsch
Offline