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

#1 2012-07-20 15:33:13

PopTarties
Scratcher
Registered: 2012-05-29
Posts: 19

Successful .block File!

The Is a successful block importer/Patch importer I made!
use this block importer:
open workspace and enter:

Code:

'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 18 June 2010 at 5:06:17 pm'!

!ScratchFileChooserDialog methodsFor: 'initialization'!
createBlockFileChooserFor: t1 
    scratchFrame _ nil.
    readingScratchFile _ true.
    list _ ScratchFilePicker new extensions: #(#block ).
    self removeAllMorphs.
    bottomSpacer delete.
    bottomSpacer _ nil.
    mainColumn addMorphBack: list.
    self title: 'Import Block'.
    list scratchInfoClient: nil.
    mainColumn addMorphBack: (Morph new extent: 5 @ 9;
         color: Color transparent);
     addMorphBack: newTitleBin.
    fileInfoColumn addMorphBack: buttonRow.
    self addMorphBack: shortcutColumn;
     addMorphBack: mainColumn;
     addMorphBack: fileInfoColumn! !

!ScratchFileChooserDialog methodsFor: 'initialization'!
createPatchFileChooserFor: t1
    scratchFrame _ nil.
    readingScratchFile _ true.
    list _ ScratchFilePicker new extensions: #(#patch ).
    self removeAllMorphs.
    bottomSpacer delete.
    bottomSpacer _ nil.
    mainColumn addMorphBack: list.
    self title: 'Import Patch'.
    list scratchInfoClient: nil.
    mainColumn addMorphBack: (Morph new extent: 5 @ 9;
         color: Color transparent);
     addMorphBack: newTitleBin.
    fileInfoColumn addMorphBack: buttonRow.
    self addMorphBack: shortcutColumn;
     addMorphBack: mainColumn;
     addMorphBack: fileInfoColumn! !


!ScratchFrameMorph methodsFor: 'menu/button actions'!
addPatch
    | t1 t2 t3 t4 |
    t1 _ ScratchFileChooserDialog new createPatchFileChooserFor: self;
             type: #patch.
    t2 _ t1 getUserResponse.
    t2 = #cancelled ifTrue: [^ self].
    t3 _ (FileDirectory forFileName: t2)
                oldFileNamed: t2.
    t4 _ t3 contentsOfEntireFile.
    (ReadWriteStream
        on: t4
        from: 1
        to: t4 size) fileIn! !

!ScratchFrameMorph methodsFor: 'menu/button actions'!
addBlock
    | t1 t2 t3 t4 |
    t1 _ ScratchFileChooserDialog new createBlockFileChooserFor: self;
             type: #block.
    t2 _ t1 getUserResponse.
    t2 = #cancelled ifTrue: [^ self].
    t3 _ (FileDirectory forFileName: t2)
                oldFileNamed: t2.
    t4 _ t3 contentsOfEntireFile.
    (ReadWriteStream
        on: t4
        from: 1
        to: t4 size) fileIn! !

!ScratchFrameMorph methodsFor: 'menu/button actions'!
fileMenu: t1
    | t2 |
    t2 _ CustomMenu new.
    t2 add: 'New' action: #newScratchProject.
    t2 add: 'Open' action: #openScratchProject.
    t2 add: 'Save' action: #saveScratchProjectNoDialog.
    t2 add: 'Save As' action: #saveScratchProject.
    t2 addLine.
    t2 add: 'Import Project' action: #importScratchProject.
    t2 add: 'Export Sprite' action: #exportSprite.
    t2 addLine.
    t2 add: 'Import Patch' action: #addPatch.
    t2 add: 'Import Block' action: #addBlock.
    t2 addLine.
    t2 add: 'Project Notes' action: #editNotes.
    Sensor shiftPressed
        ifTrue:
            [t2 addLine.
            t2 add: 'Write Project Summary' action: #writeSummaryFile.
            t2 add: 'Write Multiple Project Summaries' action: #writeMultipleSummaries].
    t2 addLine.
    t2 add: 'Quit' action: #quitScratch.
    t2 localize.
    #(2 4 5 6 7 8 ) do: [:t3 | t2 labels at: t3 put: ((t2 labels at: t3)
                copyFrom: 1 to: (t2 labels at: t3) size - 1)
                , ScratchTranslator ellipsesSuffix].
    t2 invokeOn: self at: t1 bottomLeft + (0 @ 10)! !

Enjoy!

Last edited by PopTarties (2012-07-22 12:01:28)


http://scratch.mit.edu/static/icons/buddy/1391630_med.png?t=2012-07-23+14%3A18%3A37

Offline

 

#2 2012-07-20 16:39:06

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Successful .block File!

I'm sorry, but didn't dreamod already do this?   hmm

http://scratch.mit.edu/projects/dreamod/2482921

Last edited by Greenatic (2012-07-20 16:40:22)

Offline

 

#3 2012-07-21 06:43:07

PopTarties
Scratcher
Registered: 2012-05-29
Posts: 19

Re: Successful .block File!

i didn't know about dreammod when i made this


http://scratch.mit.edu/static/icons/buddy/1391630_med.png?t=2012-07-23+14%3A18%3A37

Offline

 

#4 2012-07-21 18:27:32

chanmanpartyman
Scratcher
Registered: 2011-05-30
Posts: 500+

Re: Successful .block File!

PopTarties wrote:

i didn't know about dreammod when i made this

You should still change it to the second working .block file ever made.

Offline

 

Board footer