< Scratch File Format (1.4)

Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective. For information on the feature that replaced this one, see Scratch File Format (3.0).
all scripts are converted to tuples before they are saved; each stack is converted to: (where () indicates an array)

(position (block1 block2 block3 ...))
each block is converted to:
(selector arg1 arg2 arg3 ...)
if the argument is a number, string, boolean, or color it is just included as the (n+1)th member of the array. If it is a block, the block is converted to a tuple and included in the correct place.

– nxIII, ar-post:1043186

For example, the script:

when I receive [message v]:: control
set [var v] to ([sqrt v] of (100))
repeat until <(var)=[1]>
	wait ((3) - (2)) secs
	change [var v] by (-1)
end
say (join [hello ] [world])
if <<touching [Sprite1 v]?> or <key [space v] pressed?>> {
	broadcast [message v]:: control
	switch to costume [costume1 v]:: looks
}:: control

Gets encoded something like this:

(
    Point(20, 20.0),
    [
        [<#EventHatMorph>, 'message'],
        [<#changeVariable>, 'var', <#setVar:to:>, [<#computeFunction:of:>, 'sqrt', 100]],
        [<#doUntil>, [<#=>, [<#readVariable>, 'var'], '1'],
            [
                [<#wait:elapsed:from:>, [<#->, 3, 2]],
                [<#changeVariable>, 'var', <#changeVar:by:>, -1]
            ]
        ],
        [<#say:>, [<#concatenate:with:>, 'hello ', 'world']],
        [<#doIf>,
            [<#|>, [<#touching:>, <ScratchSpriteMorph(Sprite1)>], [<#keyPressed:>, 'space']],
            [
                [<#broadcast:>, 'message'],
                [<#lookLike:>, 'costume1']
            ]
        ]
    ]
)

Where <#say:> represents the Squeak Symbol "say:", and [] is used interchangeably with () for tuples. (Whitespace added for clarity.)

See Also

  • Blockmaking FAQs to find information on block types (blockspecs)
  • A post by ScratchReallyROCKS explaining the anatomy of a Scratch block


Cookies help us deliver our services. By using our services, you agree to our use of cookies.