This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-05-16 00:02:37

dgd
Scratcher
Registered: 2007-05-15
Posts: 1

view source code of project to show how vars/ functions/ loops work

If I'm teaching programming in Scratch, I want to be able to show students the code that produces the results seen by students.

How do I view the source code for the programs that students create... I don't want the source code of Scratch! I just want to show students that code is not pretty blocks.

thanks
Dennis

Offline

 

#2 2007-05-16 03:52:54

StuartHX
Scratcher
Registered: 2007-05-16
Posts: 1

Re: view source code of project to show how vars/ functions/ loops work

Hi

Unlike Dennis I am interested in the source code and how Scratch was written and compiled but I don't seem to be able to find anywhere on the site where this aspect of the program is revealed or discussed.... a pity because it could be very instructive for application developers in many ways. Can you help us MIT?

Offline

 

#3 2007-05-16 07:52:07

johnm
Scratcher
Registered: 2007-03-08
Posts: 100+

Re: view source code of project to show how vars/ functions/ loops work

Hi, dgd and StuartHX.

The blocks actually *are* the code. (They are interpreted in place, not compiled into another form). However, it can instructive to show students the same code in a different form. Assuming you have Scratch 1.0.2 or later, you can dump a text description of the entire project, including the blocks, by holding shift as you click on the Extras menu. Then release the shift key and select "writeProjectSummary". This will generate a text file in the Scratch folder with the "code" of the current project.

Stuart, we do plan to release the source code later this year. Check the website in a few months for news.

  -- John

Offline

 

#4 2007-05-16 10:42:28

lramon
Scratcher
Registered: 2007-05-16
Posts: 3

Re: view source code of project to show how vars/ functions/ loops work

Hi all,

I've taken a look on the summary generated by Scratch from one project. I have found that some strings appear empty:

Code:

    when I receive "disparo2"
        go to " "
        point in direction direccion2
        move 10 steps
        show
        forever 
            move 10 steps
            if touching " "? 
                hide
                stop script
            wait 0.01 secs
    end

Where it should say:

Code:

    when I receive "disparo2"
        go to "bomber"
        point in direction direccion2
        move 10 steps
        show
        forever 
            move 10 steps
            if touching "edge"? 
                hide
                stop script
            wait 0.01 secs
    end

Am I doing something wrong? Is it a bug?

Also, I'd like to ask if the project fileformat will be available. I am considering to spend some of my spare time into programming a translator that outputs a J2ME MIDlet from a Scratch project...

Best regards!

Offline

 

#5 2007-05-17 11:58:33

delza
Scratcher
Registered: 2007-03-08
Posts: 26

Re: view source code of project to show how vars/ functions/ loops work

johnm wrote:

Assuming you have Scratch 1.0.2 or later, you can dump a text description of the entire project, including the blocks, by holding shift as you click on the Extras menu. Then release the shift key and select "writeProjectSummary". This will generate a text file in the Scratch folder with the "code" of the current project.  -- John

This is very cool and I can see ways to use it to write external tools for interacting with scratch in more advanced ways.  For instance, you could use this format to export to Flash or Quicktime.  Or you could start a project in Scratch and move to, say, PyGame, when you exceeded the limitations of Scratch.

Any chance of a round-trip mechanism?  I.e., how can a third-party application write a Scratch project file?

I'm hoping to make Scratch more of an ecosystem than an island.

--Dethe

Offline

 

Board footer