Posts: 8
Joined: Mon Nov 02, 2015 8:16 pm

NuScratch Source

Thu Jan 21, 2016 10:22 pm

Hey... I'm not sure if this is the place to put this, but I am developing a project in Squeak that is based off Scratch, and would like it optomized for the Raspberry Pi. I saw NuScratch and saw that it will fit my purposes. But as I ran the *.image file, I noticed that whenever I tried to edit the source code (I am using the November 11th 2015 image), I get an error that says:

Code: Select all

MessageNotUnderstood: UndefinedObject>>position
After searching through the code, I found out that this is because squeak has a reliance on the changes and sources file included with squeak. Otherwise, I can't edit the source to add modifications.

In the version of NuScratch that run in the Sqeak 4.5 VM or lower, I could edit the source without needing a *.sources file attached. Now, though, trying to edit the source gives the above error. Can someone (@timrowledge !) please supply a source code file(s) for the newest version of NuScratch?


EDIT: I've looked through the source, and this can be fixed in future releases by setting the method #acceptsLoggingOfCompilation to report false. I achieved this by running this code:

Code: Select all

CompiledMethodTrailer class compile: 'sourcePointerInFile: t1

^ self new' classified: 'as yet unclassified' withStamp: 'SOURCECODE' notifying: nil logSource: false

Posts: 1
Joined: Wed Sep 20, 2017 11:32 pm

Re: NuScratch Source

Wed Sep 20, 2017 11:35 pm

Hi - I'm running into this same issue while trying to edit a couple things inside the NuScratch image, and this seems to be the only relevant post on the internet. How would one work around this error? I cannot change the sourcePointerInFile code to the newer version that you suggest, since it keeps throwing the same "UndefinedObject(Object)>>doesNotUnderstand: #position" error.

Posts: 1158
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: NuScratch Source

Fri Sep 22, 2017 12:12 am

I'm not sure how I missed the original post, but it was nearly two years ago.

Anyway, you are doing it wrong(™).

You don't expect to be able to open up behind the scenes of a Excel and read the sources, make changes and carry on; you can't expect a reliable development experience by trying the same with NuScratch. The release version provided on your Pi has all sorts of stuff turned off and removed and locked. One of the major things missing is the .sources file - and not just any .sources file but the very specific one that was in use by the development system just before the production release button was pressed. This is because the image has pointers into the file to fid the code for each method; when it does not find that it can decompile the machine code to present you with something readable but not terribly pretty. Once upon a time it was also possible to compile code in this state, which certainly has some uses when trying to rescue a broken system, but right now there is no way to make that work. And most certainly it is not a smart way to develop anything!

The proper way to get the sources for NuScratch in a form that lets you do development work is pretty simple.
  • Download a clean Squeak 5.1 system into a suitable directory (I'd suggest 'squeak' might be sensible)

    Code: Select all

  • Code: Select all

    unzip Squeak5.1-16549-32bit/
  • Code: Select all

    mv  Squeak5.1-16549-32bit/Squeak5.1-16549-32bit-201608171728-ARMv6 Squeak5.1
    (just to save finger damage!)
  • Code: Select all

    cd Squeak5.1
  • Code: Select all

    to run the default clean release image.
At this point you will have nice clean system that will be asking you to configure it for your preferences, so click on the 'configure' button and follow the (hopefully) easy process to set a few things up. Once you've done that click on the mouse logo at top-left to show the menu and click on 'save'. That will save the current state - with your preferences - as the default system you can use from now on.

I really, really, urge you to follow this up with a 'save as..' from the same menu and choose a new name to save a copy to do your actual work in. That way, when you manage to utterly break something you have a nice clean system ready to go and work out what you messed up. Try to use a meaningful name so that in six months time when you look around your files it gives you a decent clue what you were doing!

So, now you have a ready-to-go Squeak 5.1 system. I'm not going to type in a full tutorial here because if you're actually wanting to do some development you are going to need to do some studying and become conversant with the tools, just like any other language. As a decent, though slightly out of date, start, try ... 98DF14788D which is a nicely done youtube playlist of basic tutorials. After that, join the squeak mailing list (see and start asking questions.

Assuming you've now gained some comfort in using the system I can now give a quick run-down of loading NuScratch.

In order to work on the development system you first need to download some Scratch related resources from MIT

Code: Select all

cd {your chosen directory}/shared
Under the 'Apps' menu you will find the 'SqueakMap Catalog'. Open that and as with most catalog services, click on the 'Update' button first. It should take a moment to load the current database, so you do need to be online. Then again, to install NuScratch you would expect to be online anyway, right? If you scroll down the upper-left list a little you will see 'NuScratch' and 'NuScratchGPIO' shown. The NuScratchGPIO system includes the gpio controlling stuff specific to Raspbian, and takes a bit more setting up so leave that for now. Click on it and then on the 'Install' button.
After a moment or two you should have a bunch of new classes in your browser with all the Scratch code ready to be worked on. If you want to make a real release at some point, feel free to contact me to discuss the procedure (tim at rowledge dot org)
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

Return to “Scratch”