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

#51 2011-11-16 01:24:09

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: Developing BLOCK files.

Like a

movestep.block

kind of thing?

Great idea! I'll help!


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#52 2011-11-16 07:37:12

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Developing BLOCK files.

Are you still working on this? Because this is really simple.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#53 2011-11-16 10:44:56

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Developing BLOCK files.

FINALLY WE GET BACK TO THIS. Oh and I made the block file. Once I get home I will show you a.new way I've been thinking of doing this my other one was a.bit... Messy. The new one will request.more methods but it will work... I hope...


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#54 2011-11-16 10:50:58

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Developing BLOCK files.

I'll try explaining using this Android but I cent promise you will get it.  tongue

Basically it would make a empty blockspec for every block, then it would...
How was it that I wasn't.planning... Oh right, it would add t1 _ self blockspecforblabla for every block in the library to The end.of blockspecs.
Then it would add.the.methods and add the block to its own blockspec!
It's foolproof!


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#55 2011-11-16 10:54:23

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Developing BLOCK files.

This would.mean everytime we get a new block we would need to have on that block file.the newer blocks on every block, but It it the only way I see as.you can't make a file in only add.to. file.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#56 2011-11-16 10:56:50

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Developing BLOCK files.

Unless.we aproach this in a different way... If we made a method which would be.able.to make a new.block... Are.you thinking.what.I'm thinking?


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#57 2011-11-16 10:59:04

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

Pecola1 wrote:

Unless.we aproach this in a different way... If we made a method which would be.able.to make a new.block... Are.you thinking.what.I'm thinking?

Yeah, I had an idea like that.

Math, what do you have?

Offline

 

#58 2011-11-16 16:04:59

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Developing BLOCK files.

scimonster wrote:

Pecola1 wrote:

Unless.we aproach this in a different way... If we made a method which would be.able.to make a new.block... Are.you thinking.what.I'm thinking?

Yeah, I had an idea like that.

Math, what do you have?

My other idea would be easier to code but afterwards for updates would take a bit longer.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#59 2012-02-03 15:00:08

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: Developing BLOCK files.

BUMP!
Will someone finish this? I have a block importer doing nothing in my version of Scratch!!


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#60 2012-03-05 12:42:41

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Developing BLOCK files.

I'm working on a block importer and I think I have a good idea of how you can file in the blockspec and code. I will make the patch when I'm done.

p.s.
If anybody says 'necropost' I am going to go mad.

Offline

 

#61 2012-03-05 17:40:56

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

Re: Developing BLOCK files.

dreamod wrote:

I'm working on a block importer and I think I have a good idea of how you can file in the blockspec and code. I will make the patch when I'm done.

p.s.
If anybody says 'necropost' I am going to go mad.

It's just a month gap, not a necropost.   smile

Offline

 

#62 2012-03-06 10:32:28

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Developing BLOCK files.

I'm almost done with the code. I just need to fix a few bugs.

Offline

 

#63 2012-03-06 14:59:32

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Developing BLOCK files.

Ok, done with the code.

Code:

 'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 18 June 2010 at 5:06:17 pm'
!ScriptableScratchMorph subclass: #CustomBlockSpecsMorph
    instanceVariableNames: ''
    classVariableNames: 'CustomBlockSpecs NewestBlock'
    poolDictionaries: ''
    category: 'Scratch-Objects'! 

!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! !


!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.
        CustomBlockSpecsMorph updateCustomBlocks! !

!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 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)! !
!CustomBlockSpecsMorph class methodsFor: 'other'!
updateCustomBlocks
    CustomBlockSpecs ifNil: [CustomBlockSpecs _ #('obsolete' )].
    NewestBlock _ self getNewestBlock.
    CustomBlockSpecs _ CustomBlockSpecs , NewestBlock! !

!CustomBlockSpecsMorph class methodsFor: 'custom block specs'!
customBlockSpecs
    ^ CustomBlockSpecs! !

!CustomBlockSpecsMorph class methodsFor: 'custom block specs'!
newestBlock
    ^ NewestBlock! !

!CustomBlockSpecsMorph methodsFor: 'custom blockspecs'!
nameThatProbablyWontBeUsedAsASelectorInABlock
    ^ self! !

You will also have to replace the last line of
Scratch-Objects/ScriptableScratchMorph(class)/blockspecs/blockspecs
with: ^ t1 , self obsoleteBlockSpecs , CustomBlockSpecsMorph customBlockSpecs.
You have to import a block to make it work though.

Here is a nice block made by Greenatic made into .block format by me.

http://www.mediafire.com/?qtpvu2zzsb231ab

For more information about block files go here: http://scratch.mit.edu/forums/viewtopic.php?pid=1164646

Please report glitches.
Now I'm going to make the block file creator!

Offline

 

#64 2012-03-19 16:04:11

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Developing BLOCK files.

*update*
Ok. I have made an update. The patch got a little bigger, but I'm sure you won't mind.

Code:

Code:

 'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 17 March 2012 at 1:51:00 pm'!
ScriptableScratchMorph subclass: #CustomBlockSpecsDictionary
    instanceVariableNames: ''
    classVariableNames: 'CustomBlockSpecs NewestBlock '
    poolDictionaries: ''
    category: 'Scratch-Objects'!
DialogBoxMorph subclass: #CustomBlockSpecsEditor
    instanceVariableNames: 'scratchFrame newCustomBlockSpecs '
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Scratch-UI-Dialogs'!
DialogBoxMorph subclass: #CreateBlockDialog
    instanceVariableNames: 'blockName helpButtonMorph blockSelectorMorph receiver blockArgsMorph blockTypeMorph editorMorph blockInserterMorph blockSectionMorph blockSelector '
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Scratch-UI-Dialogs'!
DialogBoxMorph subclass: #ScrollingStringDialog
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Scratch-UI-Dialogs'!

!CustomBlockSpecsDictionary commentStamp: '<historical>' prior: 0!
Written By Dreamod.
When you import a block the block spec is stored as a method under 'custom block specs' like this: 

forward: t1
    ^ ('motion' ('move %n steps' #- #forward: 10)) 

These can be deleted at any point in the browser but are useful to recover data. The block specs are stored into the class variable 'CustomBlockSpecs'
Selecting 'Delete All Custom Blocks' from the blocks menu will only replace 'CustomBlockSpecs' with this: 

#('obsolete' 'motion' #- 'control' #- 'looks' #- 'sensing' #- 'sound' #- 'operators' #- 'pen' #- 'variables' 'lists' 'obsolete' )

All block writing is stored in CommandBlockMorph!
!CustomBlockSpecsDictionary class methodsFor: 'accessing'!
customBlockSpecs
    CustomBlockSpecs ifNil: [self updateCustomBlocks].
    ^ CustomBlockSpecs! !
!CustomBlockSpecsDictionary class methodsFor: 'accessing'!
newestBlock
    ^ NewestBlock! !
!CustomBlockSpecsDictionary class methodsFor: 'initialization'!
removeCustomBlocks
    | t1 t2 t3 t4 |
    CustomBlockSpecs _ nil.
    ScriptableScratchMorph new makeFile: 'temporaryFile.cs'.
    ScriptableScratchMorph new clearFile: 'temporaryFile.cs'.
    ScriptableScratchMorph new writeText: '!!CustomBlockSpecsDictionary class methodsFor: ''initialization''!!
getNewestBlock
    ^ #(''obsolete'')!! !!' toFile: 'temporaryFile.cs'.
    t3 _ (FileDirectory forFileName: 'temporaryFile.cs')
                oldFileNamed: 'temporaryFile.cs'.
    t4 _ t3 contentsOfEntireFile.
    (ReadWriteStream
        on: t4
        from: 1
        to: t4 size) fileIn.
    CustomBlockSpecsDictionary updateCustomBlocks.
    ScriptableScratchMorph new deleteFile: 'temporaryFile.cs'! !
!CustomBlockSpecsDictionary class methodsFor: 'accessing'!
updateBlocks
    CustomBlockSpecs _ self editBlocks! !
!CustomBlockSpecsDictionary class methodsFor: 'accessing'!
getNewestBlock
    ^ #('obsolete' )! !
!CustomBlockSpecsDictionary class methodsFor: 'custom block specs'!
editBlocks
    ^ #('obsolete' 'motion' #- 'control' #- 'looks' #- 'sensing' #- 'sound' #- 'operators' #- 'pen' #- 'variables' 'lists' 'obsolete')! !
!CommandBlockMorph methodsFor: 'export block'!
createBlock
    | t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 |
    t13 _ CreateBlockDialog new editBlockNamed: '' reciever: '';
             getUserResponse.
    t13 = #cancelled ifTrue: [^ self].
    t1 _ t13 at: 2.
    t3 _ t13 at: 4.
    t5 _ t13 at: 1.
    t6 _ StringDialog ask: 'comment?'.
    t6 = #cancelled | t6 = '' ifTrue: [^ self].
    (t6 findString: '!!')
        > 0
        ifTrue: 
            [
            [DialogBoxMorph inform: 'The character ''!!'' is reserved!! please choose a new comment without a ''!!'''.
            t6 _ StringDialog ask: 'comment?'.
            t6 = #cancelled ifTrue: [^ self].
            nil].
            (t6 findString: '!!')
                > 0 ifTrue: [DialogBoxMorph inform: 'The character ''!!'' is reserved!! please choose a new comment without a ''!!''' asUTF8].
            t6 _ StringDialog ask: 'comment?'.
            t6 = #cancelled ifTrue: [^ self].
            (t6 findString: '!!')
                > 0 ifTrue: [^ self]].
    t11 _ t6.
    (t6 findString: 'moreCodes')
        > 0
        ifTrue: 
            [(t6 findString: ':')
                > 0 ifTrue: [t14 _ (ScriptableScratchMorph new
                            letters: (t6 findString: ':')
                                    + 2
                            through: (t6 findString: ':')
                                    + 2
                            of: t6) asNumberNoError].
            (t6 findString: ';')
                > 0 ifTrue: [t11 _ ScriptableScratchMorph new
                            letters: (t6 findString: ';')
                                    + 1
                            through: t6 size
                            of: t6]].
    t4 _ ScratchFileChooserDialog
                chooseNewFileDefaultBlocks: t1
                title: 'Export Block As ' , t5
                type: '.block'.
    t4 = #cancelled ifTrue: [^ self].
    t2 _ t13 at: 3.
    (t4 asLowercase endsWith: '.block')
        ifFalse: [t4 _ t4 , '.block'].
    ScriptableScratchMorph new makeFile: t4.
    ScriptableScratchMorph new clearFile: t4.
    ScriptableScratchMorph new writeText: '!!CustomBlockSpecsDictionary class methodsFor: ''custom block specs''!!
' toFile: t4.
    t10 _ (t13 at: 5) lines at: 1.
    ScriptableScratchMorph new writeText: t10 toFile: t4.
    ScriptableScratchMorph new writeText: '    ^ #(''' , t5 , ''' ' , '(''' , t1 , '''' , ' #' , t2 , ' #' , t3 , '))' toFile: t4.
    ScriptableScratchMorph new writeText: '
' , '"' , t11 , '" !! !!
' toFile: t4.
    t2 = 's' | t2 = 'c'
        ifTrue: 
            [t8 _ 'ScratchProcess'.
            t9 _ '''private-special forms''']
        ifFalse: 
            [t8 _ 'ScriptableScratchMorph'.
            t9 _ '''' , t5 , ' ops'''].
    ScriptableScratchMorph new writeText: '!!' , t8 , ' methodsFor:' , '' , t9 , '' , '!!' toFile: t4.
    t7 _ t13 at: 5.
    ScriptableScratchMorph new writeText: t7 , '!! !!' toFile: t4.
    ScriptableScratchMorph new writeText: '
!!CustomBlockSpecsDictionary class methodsFor: ''custom block specs''!!' toFile: t4.
    ScriptableScratchMorph new writeText: '

getNewestBlock' toFile: t4.
    t10 _ self getNewTitleWithOutVariables: t13.
    ScriptableScratchMorph new writeText: '
^ self ' , t10 toFile: t4.
    ScriptableScratchMorph new writeText: '!! !!' toFile: t4.
    t14 ifNil: [t14 _ 1].
    t14
        timesRepeat: [(t6 findString: 'moreCodes')
                > 0
                ifTrue: 
                    [(t6 findString: 'moreCodes:')
                        > 0 ifTrue: [t12 _ ScriptableScratchMorph new
                                    letters: (ScriptableScratchMorph new index: ':' of: t11)
                                            + 1
                                    through: (ScriptableScratchMorph new index: ':' of: t6)
                                            + 1
                                    of: t6].
                    ScriptableScratchMorph new writeText: (self moreCustomCodes: t12)
                        toFile: t4]].
    t3 _ (FileDirectory forFileName: t4)
                oldFileNamed: t4.
    t4 _ t3 contentsOfEntireFile.
    (ReadWriteStream
        on: t4
        from: 1
        to: t4 size) fileIn.
    CustomBlockSpecsDictionary updateCustomBlocks! !
!CommandBlockMorph methodsFor: 'export block'!
exportBlock
    | t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 |
    t1 _ self commandSpec.
    t3 _ self selector.
    t5 _ self getCategoryForSelector: t3.
    t6 _ StringDialog ask: 'comment?'.
    t6 = #cancelled ifTrue: [^ self].
    (t6 findString: '!!')
        > 0
        ifTrue: 
            [DialogBoxMorph inform: 'The character ''!!'' is reserved!! please choose a new comment without a ''!!'''.
            t6 _ StringDialog ask: 'comment?'.
            t6 = #cancelled ifTrue: [^ self].
            (t6 findString: '!!')
                > 0 ifTrue: [DialogBoxMorph inform: 'The character ''!!'' is reserved!! please choose a new comment without a ''!!''' asUTF8].
            t6 _ StringDialog ask: 'comment?'.
            t6 = #cancelled ifTrue: [^ self].
            (t6 findString: '!!')
                > 0 ifTrue: [^ self]].
    t11 _ t6.
    (t6 findString: 'moreCodes')
        > 0
        ifTrue: 
            [(t6 findString: ':')
                > 0 ifTrue: [t13 _ (ScriptableScratchMorph new
                            letters: (t6 findString: ':')
                                    + 2
                            through: (t6 findString: ':')
                                    + 2
                            of: t6) asNumberNoError].
            (t6 findString: ';')
                > 0
                ifTrue: [t11 _ ScriptableScratchMorph new
                                letters: (t6 findString: ';')
                                        + 1
                                through: t6 size
                                of: t6]
                ifFalse: [t11 _ 'no comment available']].
    t4 _ ScratchFileChooserDialog
                chooseNewFileDefaultBlocks: t1
                title: 'Export Block As ' , t5
                type: '.block'.
    t4 = #cancelled ifTrue: [^ self].
    (self isKindOf: CommandBlockMorph)
        ifTrue: [t2 _ '-'].
    (self isKindOf: ReporterBlockMorph)
        ifTrue: 
            [self isReporter ifTrue: [t2 _ 'r'].
            self isBooleanReporter ifTrue: [t2 _ 'b']].
    (self isKindOf: CBlockMorph)
        | (self isKindOf: IfElseBlockMorph) ifTrue: [t2 _ 'c'].
    (self isKindOf: SetterBlockMorph)
        | (self isKindOf: VariableBlockMorph) | (self isKindOf: ListContentsBlockMorph) | (self isKindOf: HatBlockMorph) ifTrue: [^ self beep].
    self isTimed ifTrue: [t2 _ 't'].
    self isSpecialForm & (self isKindOf: CBlockMorph) not & (self isKindOf: IfElseBlockMorph) not ifTrue: [t2 _ 's'].
    (t4 asLowercase endsWith: '.block')
        ifFalse: [t4 _ t4 , '.block'].
    ScriptableScratchMorph new makeFile: t4.
    ScriptableScratchMorph new clearFile: t4.
    ScriptableScratchMorph new writeText: '!!CustomBlockSpecsDictionary class methodsFor: ''custom block specs''!!
' toFile: t4.
    t10 _ self getNewTitleWithVariables.
    ScriptableScratchMorph new writeText: t10 toFile: t4.
    ScriptableScratchMorph new writeText: '    ^ #(''' , t5 , ''' ' , '(''' , t1 , '''' , ' #' , t2 , ' #' , t3 , '))' toFile: t4.
    ScriptableScratchMorph new writeText: '
' , '"' , t11 , '" !! !!
' toFile: t4.
    self isSpecialForm | (self isKindOf: CBlockMorph)
        ifTrue: 
            [t8 _ 'ScratchProcess'.
            t9 _ '''private-special forms''']
        ifFalse: 
            [t8 _ 'ScriptableScratchMorph'.
            t9 _ '''' , t5 , ' ops'''].
    ScriptableScratchMorph new writeText: '!!' , t8 , ' methodsFor:' , '' , t9 , '' , '!!' toFile: t4.
    t7 _ self getCode.
    ScriptableScratchMorph new writeText: t7 , '!! !!' toFile: t4.
    ScriptableScratchMorph new writeText: '
!!CustomBlockSpecsDictionary class methodsFor: ''custom block specs''!!' toFile: t4.
    ScriptableScratchMorph new writeText: '

getNewestBlock' toFile: t4.
    t10 _ self getNewTitleWithOutVariables.
    ScriptableScratchMorph new writeText: '
^ self ' , t10 toFile: t4.
    ScriptableScratchMorph new writeText: '!! !!' toFile: t4.
    t13 ifNil: [t13 _ 1].
    t13
        timesRepeat: [(t6 findString: 'moreCodes')
                > 0
                ifTrue: 
                    [(t6 findString: 'moreCodes:')
                        > 0 ifTrue: [t12 _ ScriptableScratchMorph new
                                    letters: (ScriptableScratchMorph new index: ':' of: t11)
                                            + 1
                                    through: (ScriptableScratchMorph new index: ':' of: t6)
                                            + 1
                                    of: t6].
                    ScriptableScratchMorph new writeText: (self moreCodes: t12)
                        toFile: t4]]! !
!CommandBlockMorph methodsFor: 'export block'!
getCategoryForSelector: t1 
    | t2 t3 t4 t5 t6 |
    t2 _ ScriptableScratchMorph selectors asString.
    (t2 findString: t1 asString)
        > 0
        ifTrue: [t2 _ ScriptableScratchMorph]
        ifFalse: [t2 _ nil].
    t2
        ifNil: 
            [t2 _ ScratchSpriteMorph selectors asString.
            (t2 findString: t1 asString)
                > 0
                ifTrue: [t2 _ ScratchSpriteMorph]
                ifFalse: [t2 _ nil]].
    t2
        ifNil: 
            [t2 _ ScratchStageMorph selectors asString.
            (t2 findString: t1 asString)
                > 0
                ifTrue: [t2 _ ScratchStageMorph]
                ifFalse: [t2 _ ScriptableScratchMorph]].
    t2 ifNil: [t2 _ ScriptableScratchMorph].
    t6 _ t1 asString.
    t3 _ ScriptableScratchMorph blockSpecCategories.
    t5 _ 1.
    t3 size
        timesRepeat: 
            [t4 _ (t2 blockSpecsForCategory: (t3 at: t5)) asString.
            (t4 findString: t6 asString)
                > 0 ifTrue: [^ (t3 at: t5) asString].
            t5 _ t5 + 1.
            t5 > t3 size ifTrue: [^ 'motion'].
            nil].
    DialogBoxMorph inform: t4! !
!CommandBlockMorph methodsFor: 'export block'!
getCode
    | t1 t2 |
    t1 _ self selector.
    t2 _ ScriptableScratchMorph selectors asString.
    (t2 findString: t1 asString)
        > 0 ifTrue: [^ (ScriptableScratchMorph sourceCodeAt: t1) asString].
    t2 _ ScratchSpriteMorph selectors asString.
    (t2 findString: t1 asString)
        > 0 ifTrue: [^ (ScratchSpriteMorph sourceCodeAt: t1) asString].
    t2 _ ScratchStageMorph selectors asString.
    (t2 findString: t1 asString)
        > 0 ifTrue: [^ (ScratchStageMorph sourceCodeAt: t1) asString].
    t2 _ ScratchProcess selectors asString.
    (t2 findString: t1 asString)
        > 0 ifTrue: [^ (ScratchProcess sourceCodeAt: t1) asString]! !
!CommandBlockMorph methodsFor: 'export block'!
getNewTitleWithOutVariables
    | t1 |
    t1 _ self selector.
    ^ t1 asString copyReplaceAll: ':' with: ': '' '! !
!CommandBlockMorph methodsFor: 'export block'!
getNewTitleWithOutVariables: t1 
    | t2 |
    t2 _ t1 at: 4.
    (t2 findString: ' ')
        > 0 ifFalse: [t2 _ t2 , ' '].
    t2 _ ScriptableScratchMorph new
                letters: 1
                through: (t2 findString: ' ')
                of: t2.
    ^ t2 asString copyReplaceAll: ':' with: ': '' '' '! !
!CommandBlockMorph methodsFor: 'export block'!
getNewTitleWithVariables
    | t1 t2 t3 t4 t5 |
    t1 _ 1.
    t2 _ ''.
    t3 _ 1.
    t4 _ self selector.
    t5 _ self argMorphs size asNumber.
    self isTimed ifTrue: [t5 _ t5 + 2].
    (t4 findString: ':')
        > 0
        ifTrue: [t5
                timesRepeat: 
                    [t2 _ t2 , (ScriptableScratchMorph new
                                    letters: t1
                                    through: (ScriptableScratchMorph new
                                            indexOf: ':'
                                            startingAt: t1
                                            in: t4)
                                    of: t4) , ' t' , t3 asString , ' '.
                    t1 _ (ScriptableScratchMorph new
                                indexOf: ':'
                                startingAt: t1
                                in: t4)
                                + 1.
                    t3 _ t3 + 1]]
        ifFalse: [t2 _ t4].
    ^ t2! !
!CommandBlockMorph methodsFor: 'export block'!
moreCodes: t1 
    | t2 t3 t4 t5 t6 t7 t8 t9 t10 |
    t2 _ StringDialog ask: 'Enter Class And Selector
' , '         (' , 'ex: ScratchFrameMorph new saveScratchProject' , ')         ' initialAnswer: 'ScratchFrameMorph new saveScratchProject'.
    (t2 findString: 'moreCodes')
        > 0
        ifTrue: [(t2 findString: ';')
                > 0 ifTrue: [t2 _ ScriptableScratchMorph new
                            letters: (t2 findString: ';')
                                    + 1
                            through: t2 size
                            of: t2]].
    t3 _ ScriptableScratchMorph new
                letters: 1
                through: (t2 findString: ' ')
                        - 1
                of: t2.
    t4 _ t2 findString: 'new'.
    t4 > 0
        ifTrue: [t4 _ ' ']
        ifFalse: [t4 _ ' class '].
    t5 _ t2 findString: ' '.
    t4 = ' ' ifTrue: [t5 _ t5 + 5].
    t6 _ 'thing' asString.
    t6 _ ScriptableScratchMorph new
                letters: t5
                through: t2 size
                of: t2.
    t7 _ t3 asString , t4 asString , 'sourceCodeAt: ' , '#' , t6 asString.
    ScriptableScratchMorph new makeFile: 'temporaryFile.cs'.
    ScriptableScratchMorph new clearFile: 'temporaryFile.cs'.
    ScriptableScratchMorph new writeText: '!!CommandBlockMorph methodsFor: ''export block''!!
writeMoreCodes
    ^ ' , t7 toFile: 'temporaryFile.cs'.
    t9 _ (FileDirectory forFileName: 'temporaryFile.cs')
                oldFileNamed: 'temporaryFile.cs'.
    t10 _ t9 contentsOfEntireFile.
    (ReadWriteStream
        on: t10
        from: 1
        to: t10 size) fileIn.
    ScriptableScratchMorph new deleteFile: 'temporaryFile.cs'.
    t8 _ self writeMoreCodes asString.
    ^ '

!!' , t3 , t4 , 'methodsFor: ''as yet unclassified''!!

' , t8 , '!! !!'! !
!CommandBlockMorph methodsFor: 'export block'!
moreCustomCodes: t1 
    | t2 t3 t4 t5 t6 t7 t8 t9 t10 |
    t2 _ StringDialog ask: 'Enter Class And Selector
' , '         (' , 'ex: ScratchFrameMorph new saveScratchProject' , ')         ' initialAnswer: 'ScratchFrameMorph new saveScratchProject'.
    (t2 findString: 'moreCodes')
        > 0
        ifTrue: [(t2 findString: ';')
                > 0 ifTrue: [t2 _ ScriptableScratchMorph new
                            letters: (t2 findString: ';')
                                    + 1
                            through: t2 size
                            of: t2]].
    t3 _ ScriptableScratchMorph new
                letters: 1
                through: (t2 findString: ' ')
                        - 1
                of: t2.
    t4 _ t2 findString: 'new'.
    t4 > 0
        ifTrue: [t4 _ ' ']
        ifFalse: [t4 _ ' class '].
    t5 _ t2 findString: ' '.
    t4 = ' ' ifTrue: [t5 _ t5 + 5].
    t6 _ 'thing' asString.
    t6 _ ScriptableScratchMorph new
                letters: t5
                through: t2 size
                of: t2.
    t8 _ CreateBlockDialog new moreCodes; getUserResponse2.
    ^ '

!!' , t3 , t4 , 'methodsFor: ''as yet unclassified''!!

' , t8 , '!! !!'! !
!CommandBlockMorph methodsFor: 'private'!
rightButtonMenu
    | t1 t2 t3 t4 |
    t1 _ CustomMenu new.
    t1 add: 'help' action: #presentHelpScreen.
    t1 add: 'export block' action: #exportBlock.
    (owner isKindOf: ScratchBlockPaletteMorph)
        ifFalse: 
            [t1 addLine.
            (#(#+ #- #* #/ #\\ ) includes: selector)
                ifTrue: [#(#+ #- #* #/ #mod ) with: #(#+ #- #* #/ #\\ ) do: [:t5 :t6 | t1 add: t5 action: t6]].
            (#(#< #= #> ) includes: selector)
                ifTrue: [#(#< #= #> ) do: [:t6 | t1 add: t6 action: t6]].
            (#(#& #| ) includes: selector)
                ifTrue: [#(#and #or ) with: #(#& #| ) do: [:t5 :t6 | t1 add: t5 action: t6]].
            t1 addLine.
            t1 add: 'duplicate' action: #duplicate.
            (self owner isKindOf: BlockMorph)
                ifFalse: [t1 add: 'delete' action: #delete]].
    t2 _ self ownerThatIsA: ScratchFrameMorph.
    (t2 notNil and: [#(#sensor: #sensorPressed: ) includes: selector])
        ifTrue: 
            [t1 addLine.
            t1 add: 'show ScratchBoard watcher' action: #showSensorBoard.
            t2 workPane scratchServer ifNil: [t1 add: 'enable remote sensor connections' action: #enableRemoteSensors]
                ifNotNil: [t1 add: 'disable remote sensor connections' action: #exitScratchSession]].
    DebugMenu
        ifTrue: 
            [t1 addLine.
            t1 add: 'show tuples' action: #showTuples].
    (t3 _ t1 localize; startUp) ifNil: [^ self].
    (#(#presentHelpScreen #duplicate #delete ) includes: t3)
        ifTrue: [^ self perform: t3].
    t3 = #showSensorBoard
        ifTrue: 
            [t2 showSensorBoard.
            ^ self].
    t3 = #enableRemoteSensors
        ifTrue: 
            [t2 enableRemoteSensors.
            ^ self].
    t3 = #exitScratchSession
        ifTrue: 
            [t2 exitScratchSession.
            ^ self].
    t3 = #exportBlock ifTrue: [^ self exportBlock].
    t3 = #showTuples ifTrue: [^ self showTuples].
    t4 _ '%n ' , t3 , ' %n'.
    '\\' = t3 ifTrue: [t4 _ ScratchTranslator translationFor: '%n mod %n'].
    '&' = t3 ifTrue: [t4 _ ScratchTranslator translationFor: '%b and %b'].
    '|' = t3 ifTrue: [t4 _ ScratchTranslator translationFor: '%b or %b'].
    self commandSpec: t4.
    self selector: t3! !
!CreateBlockDialog methodsFor: 'initialization'!
initialize
    super initialize.
    self
        withButtonsForYes: false
        no: false
        okay: true
        cancel: false! !
!CreateBlockDialog methodsFor: 'other'!
blockSection
    ^ blockSectionMorph evaluate! !
!CreateBlockDialog methodsFor: 'other'!
blockSpec
    ^ blockArgsMorph contents! !
!CreateBlockDialog methodsFor: 'other'!
blockType
    ^ blockTypeMorph contents! !
!CreateBlockDialog methodsFor: 'other'!
editBlockNamed: t1 reciever: t2 
    | t3 |
    editorMorph _ ScrollingStringMorph new borderWidth: 0;
             contents: '';
             font: self class monoSpacedFont;
             backForm: (ScratchFrameMorph skinAt: #stringFieldFrame);
             width: 300.
    blockArgsMorph _ StringFieldMorph new useStringFieldFrame; width: 250.
    blockSelectorMorph _ StringFieldMorph new useStringFieldFrame; width: 250.
    blockTypeMorph _ StringFieldMorph new useStringFieldFrame; width: 35.
    blockSectionMorph _ StringFieldMorph new useStringFieldFrame; width: 100.
    helpButtonMorph _ (self buttonLabel: ('Help' , ScratchTranslator ellipsesSuffix) localized action: #presentHelpMenu)
                width: 300.
    t3 _ AlignmentMorph new width: 300;
             color: Color transparent;
             centering: #center.
    t3 addMorph: blockSectionMorph;
     addMorph: blockTypeMorph;
     addMorph: blockArgsMorph.
    self title: 'Create A Block'.
    mainColumn addMorphBack: t3.
    mainColumn addMorphBack: blockSelectorMorph.
    mainColumn addMorphBack: editorMorph.
    mainColumn addMorphBack: helpButtonMorph.
    mainColumn addMorphBack: buttonRow.
    editorMorph contents: (ScratchSpriteMorph sourceCodeAt: #forward:) asString.
    blockArgsMorph contents: 'move %n steps' asString.
    blockTypeMorph contents: '-' asString.
    blockSectionMorph contents: 'motion'.
    blockSelectorMorph contents: 'forward: 10'.
    bottomSpacer delete.
    bottomSpacer _ nil.
    tabFields add: editorMorph.
    tabFields add: helpButtonMorph.
    tabFields add: blockArgsMorph.
    tabFields add: blockTypeMorph! !
!CreateBlockDialog methodsFor: 'other'!
getUserResponse
    | t1 t2 |
    self openInWorld.
    self centerOnScreen.
    t1 _ self world.
    tabFields size > 0 ifTrue: [t1 activeHand newKeyboardFocus: (tabFields at: 4)].
    done _ false.
    [done]
        whileFalse: [t1 doOneCycle].
    t2 _ Array
                with: blockSectionMorph contents
                with: blockArgsMorph contents
                with: blockTypeMorph contents
                with: blockSelectorMorph contents
                with: self value.
    ^ t2! !
!CreateBlockDialog methodsFor: 'other'!
getUserResponse2
    | t1 t2 |
    self openInWorld.
    self centerOnScreen.
    t1 _ self world.
    tabFields size > 0 ifTrue: [t1 activeHand newKeyboardFocus: (tabFields at: 1)].
    done _ false.
    [done]
        whileFalse: [t1 doOneCycle].
    ^ self value! !
!CreateBlockDialog methodsFor: 'other'!
moreCodes
    | t1 |
    editorMorph _ ScrollingStringMorph new borderWidth: 0;
             contents: '';
             font: self class monoSpacedFont;
             backForm: (ScratchFrameMorph skinAt: #stringFieldFrame);
             width: 300.
    t1 _ AlignmentMorph new width: 300;
             color: Color transparent;
             centering: #center.
    self title: 'Create A Block'.
    mainColumn addMorphBack: t1.
    mainColumn addMorphBack: editorMorph.
    mainColumn addMorphBack: buttonRow.
    editorMorph contents: 'message selector and argument names
    "comment stating purpose of message"

    | temporary variable names |
    statements' asString.
    bottomSpacer delete.
    bottomSpacer _ nil.
    tabFields add: editorMorph! !
!CreateBlockDialog methodsFor: 'other'!
presentHelpMenu
    | t1 t2 |
    t1 _ CustomMenu new.
    t1 add: 'arguments' action: #arguments.
    t1 add: 'type' action: #type.
    t1 add: 'name' action: #name.
    t1 add: 'selector' action: #selector.
    t1 add: 'code' action: #code.
    t2 _ t1 localize; startUp.
    t2 = #arguments ifTrue: [^ ScrollingStringDialog new text: 'Arguments are spaces where you can enter text, numbers, colors, booleans etc. They are encoded using ''%'' and a letter, ex. %s = string, %m = morph list (sprite list).
Different Scratch Mods have different arguments. Here is your list of arguments. It can be found at Scratch-Blocks>>CommandBlockMorph>>private>>uncoloredArgMorphFor:

' , (CommandBlockMorph sourceCodeAt: #uncoloredArgMorphFor:) asString , '

for information visit:  ' title: 'Help - About Arguments';
         getUserResponse].
    t2 = #type ifTrue: [^ ScrollingStringDialog new text: 'This determines the shape of your block.
        Explanation of flags:
        
        -    no flags
        b    boolean reporter
        c    c-shaped block containing a sequence of commands (always special form)
        r    reporter
        s    special form command with its own evaluation rule
        t    timed command, like wait or glide
        E    message event hat
        K    key event hat
        M    mouse-click event hat
        S    start event hat
        W    when <condition> hat (obsolete).
        
    Some modifications like panther and BYOB have even more block kinds.

' title: 'Help - Block Types';
         getUserResponse].
    t2 = #name ifTrue: [^ ScrollingStringDialog new text: 'The title of the block is the text that shows up on the block' title: 'Help - Title';
         getUserResponse].
    t2 = #selector ifTrue: [ScrollingStringDialog new text: 'The selector should be the same as the title of the code. However, instead of typing ''do: t1 ThisCode: t2 On: t3'' (example) you type ''do:ThisCode:On:''
Why do I need to type the selector?
this is important because the blockspecs builder builds the blockspec from 4 things. 
>> the category (''motion''...
>> the title (''move %n steps''...
>> the type #-
>> and the selector: forward:)

You cannot type the full blockspec because the block exporter needs all the data seperately.' title: 'Help - Selector';
         getUserResponse].
    t2 = #code ifTrue: [^ ScrollingStringDialog new text: 'The code (or method) is what make the block work. First you type the title and then you type the variables, like this: | t1 t2 t3 | 
Then you type your statements (actions)' title: 'Help - Code';
         getUserResponse]! !
!CreateBlockDialog class methodsFor: 'instance creation'!
monoSpacedFont
    ^ ScratchFrameMorph getFont: #ProjectNotes! !
!CreateBlockDialog methodsFor: 'other'!
value
    ^ editorMorph contents! !
!CustomBlockSpecsEditor class methodsFor: 'initialization'!
editNotesFor: aScratchFrameMorph
    ^ self new
        createNotesDialogFor: aScratchFrameMorph;
        extent: 350@450.! !
!CustomBlockSpecsEditor methodsFor: 'initialization'!
newCustomBlockSpecs

    ^ newCustomBlockSpecs contents! !
!CustomBlockSpecsEditor methodsFor: 'initialization'!
createNotesDialogFor: t1 
    | t2 |
    t2 _ ScratchFrameMorph getFont: #ProjectNotes.
    newCustomBlockSpecs _ ScrollingStringMorph new borderWidth: 0;
             contents: '';
             font: t2;
             backForm: (ScratchFrameMorph skinAt: #stringFieldFrame);
             width: 500.
    self title: 'Edit Custom Blockspecs'.
    mainColumn addMorphBack: newCustomBlockSpecs.
    mainColumn addMorphBack: buttonRow.
    scratchFrame _ t1.
    newCustomBlockSpecs contents: CustomBlockSpecsDictionary customBlockSpecs asString.
    bottomSpacer delete.
    bottomSpacer _ nil.
    tabFields add: newCustomBlockSpecs! !
!CustomBlockSpecsEditor methodsFor: 'initialization'!
initialize
    super initialize.
    self
        withButtonsForYes: false
        no: false
        okay: true
        cancel: true! !
!CustomBlockSpecsEditor methodsFor: 'other'!
getUserResponse
    | t1 t2 t3 t4 |
    self openInWorld.
    self centerOnScreen.
    t1 _ self world.
    t1 activeHand newKeyboardFocus: newCustomBlockSpecs.
    done _ false.
    [done]
        whileFalse: [t1 doOneCycle].
    response = #cancelled ifTrue: [^ #cancelled].
    t2 _ 'temporaryFile.cs'.
    ScriptableScratchMorph new makeFile: t2.
    ScriptableScratchMorph new clearFile: t2.
    ScriptableScratchMorph new writeText: '!!CustomBlockSpecsDictionary class methodsFor: ''custom block specs''!!

editBlocks
    ^ #' toFile: t2.
    ScriptableScratchMorph new writeText: newCustomBlockSpecs contents toFile: 'temporaryFile.cs'.
    ScriptableScratchMorph new writeText: '!! !!' toFile: t2.
    t3 _ (FileDirectory forFileName: t2)
                oldFileNamed: t2.
    t4 _ t3 contentsOfEntireFile.
    (ReadWriteStream
        on: t4
        from: 1
        to: t4 size) fileIn.
    ^ CustomBlockSpecsDictionary updateBlocks! !
!ScrollingStringDialog methodsFor: 'initialization'!
text: t1 title: t2 
    | t3 |
    t3 _ ScrollingStringMorph new borderWidth: 0;
             contents: t1;
             font: (ScratchFrameMorph getFont: #ProjectNotes);
             isEditable: false;
             backForm: (ScratchFrameMorph skinAt: #stringFieldFrame);
             width: 500.
    self title: t2.
    mainColumn addMorphBack: t3.
    buttonRow addMorphBack: (self buttonLabel: 'OK' action: #yes).
    mainColumn addMorphBack: buttonRow.
    bottomSpacer delete.
    bottomSpacer _ nil! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
createBlock
    CommandBlockMorph new createBlock! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
deleteAllBlocks
    CustomBlockSpecsDictionary removeCustomBlocks! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
editCustomBlockSpecs
    ^ (CustomBlockSpecsEditor editNotesFor: self) getUserResponse! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
createMenuPanel
    | t1 t2 |
    menuPanel _ AlignmentMorph new color: Color transparent;
             centering: #center;
             inset: 0;
             height: 0.
    self addShortcutButtonsTo: menuPanel.
    t1 _ #((#File #fileMenu:) (#Edit #editMenu:) (#Blocks #blocksMenu:) (#Help #helpMenu:) ).
    t1 do: 
        [:t3 | 
        t2 _ ScratchMenuTitleMorph new contents: (t3 at: 1) localized;
                 target: self selector: (t3 at: 2).
        menuPanel addMorphBack: t2.
        #helpMenu: = (t3 at: 2) ifFalse: [menuPanel addMorphBack: (Morph new color: Color transparent;
                 extent: 12 @ 5)]].
    topPane addMorph: menuPanel! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
blocksMenu: t1 
    | t2 |
    t2 _ CustomMenu new.
    t2 add: 'Edit Custom Block Specs' action: #editCustomBlockSpecs.
    t2 add: 'Delete All Custom Blocks' action: #deleteAllBlocks.
    t2 addLine.
    t2 add: 'Import Block' action: #addBlock.
    t2 add: 'Create Block' action: #createBlock.
    t2 invokeOn: self at: t1 bottomLeft + (0 @ 10)! !
!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.
    CustomBlockSpecsDictionary updateCustomBlocks! !
!ScratchFileChooserDialog methodsFor: 'initialization'!
createFileChooserLayoutBlock: t1 
    list _ ScratchFilePicker new.
    self removeAllMorphs.
    bottomSpacer delete.
    bottomSpacer _ nil.
    mainColumn addMorphBack: list.
    self title: 'Open'.
    t1
        ifTrue: 
            [self title: 'Save As'.
            newFileTitle _ StringMorph new contents: 'New Filename:' localized , ' ';
                     color: (Color gray: 0.3);
                     font: (ScratchFrameMorph getFont: #FileChooserNewFileTitle).
            newFileName _ StringFieldMorph new font: (ScratchFrameMorph getFont: #FileChooserNewFilename);
                     color: (Color
                            r: 211 / 255
                            g: 214 / 255
                            b: 216 / 255);
                     width: 180.
            newTitleBin addMorphBack: newFileTitle;
             addMorphBack: (Morph new extent: 5 @ 5;
                 color: Color transparent);
             addMorphBack: (Morph new extent: 5 @ 5;
                 color: Color transparent);
             addMorphBack: newFileName;
             addMorphBack: (AlignmentMorph newSpacer: Color transparent).
            ScratchTranslator isRTL ifTrue: [newTitleBin submorphs reversed do: 
                    [:t2 | 
                    t2 delete.
                    newTitleBin addMorphBack: t2]]].
    mainColumn addMorphBack: newTitleBin;
     addMorphBack: newTitleBin;
     addMorphBack: buttonRow.
    self addMorphBack: shortcutColumn;
     addMorphBack: mainColumn;
     addMorphBack: fileInfoColumn! !
!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! !
!CustomBlockSpecsDictionary class methodsFor: 'initialization'!
updateCustomBlocks
    CustomBlockSpecs ifNil: [CustomBlockSpecs _ #('obsolete' 'motion' #- 'control' #- 'looks' #- 'sensing' #- 'sound' #- 'operators' #- 'pen' #- 'variables' 'lists' )].
    NewestBlock _ self getNewestBlock.
    CustomBlockSpecs _ CustomBlockSpecs , NewestBlock! !
!ScriptableScratchMorph methodsFor: 'file ops'!
clearFile: t1 
    | t2 t3 t4 |
    t4 _ 'credit to panther'.
    t3 _ FileDirectory forFileName: t1.
    t3 deleteFileNamed: t1.
    t2 _ FileStream newFileNamed: t1.
    t2 close! !
!ScriptableScratchMorph methodsFor: 'file ops'!
deleteFile: t1 
    | t2 t3 |
    t2 _ FileDirectory forFileName: t1.
    t3 _ FileDirectory localNameFor: t1.
    t2 deleteFileNamed: t3 ifAbsent: []! !
!ScriptableScratchMorph methodsFor: 'file ops'!
makeFile: t1 
    | t2 t3 t4 t5 t6 t7 t8 t9 t10 |
    t10 _ 'credit to panther'.
    t2 _ t1.
    t9 _ t1.
    t6 _ 'I exist'.
    t3 _ self readFile: t9.
    self writeText: t6 toFile: t9.
    t5 _ self readFile: t9.
    t7 _ self stringLength: t6.
    t8 _ self stringLength: t5.
    t7 _ t8 - t7.
    t7 _ t7 + 1.
    t7 _ self
                letters: t7
                through: t8
                of: t5.
    t7 = t6
        ifTrue: 
            [t4 _ true.
            self clearFile: t9.
            t3 = '' ifFalse: [self writeText: t3 toFile: t9]]
        ifFalse: [t4 _ false].
    t4 = false ifTrue: [FileStream newFileNamed: t2]! !
!ScriptableScratchMorph methodsFor: 'file ops'!
readFile: t1 
    | t2 t3 t4 |
    t4 _ 'credit to panther'.
    (FileDirectory default fileExists: t1)
        ifFalse: [^ ''].
    t2 _ (FileStream readOnlyFileNamed: t1) binary.
    t2 ifNil: [^ ''].
    t3 _ t2 contentsOfEntireFile asString.
    t2 close.
    ^ t3! !
!ScriptableScratchMorph methodsFor: 'file ops'!
writeText: t1 toFile: t2 
    | t3 t4 |
    t4 _ 'credit to panther'.
    (FileDirectory default fileExists: t2)
        ifFalse: [^ self].
    t3 _ (FileStream fileNamed: t2) binary.
    t3 ifNil: [^ self].
    t3 setToEnd.
    t3 nextPutAll: t1.
    t3 close! !
!ScriptableScratchMorph methodsFor: 'string ops'!
letters: t1 through: t2 of: t3 
    ^ t3 asString copyFrom: (t1 max: 1)
        to: (t2 min: t3 size)! !
!ScriptableScratchMorph methodsFor: 'string ops'!
indexOf: t1 startingAt: t2 in: t3 
    ^ t3 asString findString: t1 startingAt: t2! !
!ScriptableScratchMorph methodsFor: 'string ops'!
index: t1 of: t2 
    ^ t2 findString: t1! !
!ScriptableScratchMorph class methodsFor: 'block specs'!
blockSpecs
    "Answer a collection of block specifications for the blocks that are common to all objects. Block specificatons (Arrays) are interspersed with category names (Strings). A block specification is an Array of the form: (<block spec string> <block type> <selector> [optional initial argument values]).

    Explanation of flags:
        -    no flags
        b    boolean reporter
        c    c-shaped block containing a sequence of commands (always special form)
        r    reporter
        s    special form command with its own evaluation rule
        t    timed command, like wait or glide
        E    message event hat
        K    key event hat
        M    mouse-click event hat
        S    start event hat
        W    when <condition> hat (obsolete)"

    | blocks |
    blocks _ #(
        'control'
            ('when %m clicked'                S    -)
            ('when %k key pressed'            K    -)
            ('when %m clicked'                M    -)
            -
            ('wait %n secs'                    t    wait:elapsed:from: 1)
            -
            ('forever'                        c    doForever)
            ('repeat %n'                        c    doRepeat 10)
            -
            ('broadcast %e'                    -    broadcast:)
            ('broadcast %e and wait'            s    doBroadcastAndWait)
            ('when I receive %e'            E    -)
            -
            ('forever if %b'                    c    doForeverIf)
            ('if %b'                            c    doIf)
            ('if %b'                            c    doIfElse)
            ('wait until %b'                    s    doWaitUntil)
            ('repeat until %b'                c    doUntil)
            -
            ('stop script'                    s    doReturn)
            ('stop all'                        -    stopAll)
        'operators'
            ('%n + %n'                        r    + - -)
            ('%n - %n'                        r    - - -)
            ('%n * %n'                        r    * - -)
            ('%n / %n'                        r    / - -)
            -
            ('pick random %n to %n'        r    randomFrom:to: 1 10)
            -
            ('%s < %s'                        b    < '' '')
            ('%s = %s'                        b    = '' '')
            ('%s > %s'                        b    > '' '')
            -
            ('%b and %b'                    b    &)
            ('%b or %b'                        b    |)
            ('not %b'                        b    not)
            -
            ('join %s %s'                    r    concatenate:with: 'hello ' 'world')
            ('letter %n of %s'                r    letter:of: 1 'world')
            ('length of %s'                    r    stringLength: 'world')
            -
            ('%n mod %n'                    r    \\ - -)
            ('round %n'                        r    rounded -)
            -
            ('%f of %n'                        r    computeFunction:of: 'sqrt' 10)
        'sound'
            ('play sound %S'                -    playSound:)
            ('play sound %S until done'        s    doPlaySoundAndWait)
            ('stop all sounds'                -    stopAllSounds)
            -
            ('play drum %D for %n beats'    t     drum:duration:elapsed:from: 48 0.2)
            ('rest for %n beats'                t     rest:elapsed:from: 0.2)
            -
            ('play note %N for %n beats'    t    noteOn:duration:elapsed:from: 60 0.5)
            ('set instrument to %I'            -     midiInstrument: 1)
            -
            ('change volume by %n'        -     changeVolumeBy: -10)
            ('set volume to %n%'            -     setVolumeTo: 100)
            ('volume'                        r     volume)
            -
            ('change tempo by %n'            -     changeTempoBy: 20)
            ('set tempo to %n bpm'            -     setTempoTo: 60)
            ('tempo'                            r     tempo)
        'motor'
            ('motor on for %n secs'            t    motorOnFor:elapsed:from: 1)
            ('motor on'                        -    allMotorsOn)
            ('motor off'                        -    allMotorsOff)
            ('motor power %n'                -    startMotorPower: 100)
            ('motor direction %W'            -    setMotorDirection: 'this way')
        'variables'
            ('show variable %v'                -    showVariable:)
            ('hide variable %v'                -    hideVariable:)
        'list'
            ('add %s to %L'                    -    append:toList: 'thing')
            -
            ('delete %y of %L'                -    deleteLine:ofList: 1)
            ('insert %s at %i of %L'            -    insert:at:ofList: 'thing' 1)
            ('replace item %i of %L with %s'        -    setLine:ofList:to: 1 'list' 'thing')
            -
            ('item %i of %L'                    r    getLine:ofList: 1)
            ('length of %L'                    r    lineCountOfList:)
            ('%L contains %s'                b    list:contains: 'list' 'thing')
    ).

    ^ blocks, self obsoleteBlockSpecs , CustomBlockSpecsDictionary customBlockSpecs
! !
!ScratchFileChooserDialog class methodsFor: 'instance creation'!
chooseNewFileDefaultBlocks: t1 title: t2 type: t3 
    | t4 |
    ScratchFileChooserDialog deleteDuplicates.
    t4 _ self new createFileChooserLayoutBlock: true;
             type: t3;
             defaultName: t1;
             title: t2;
             listExtent: 400 @ 280.
    ^ t4 getUserResponseForNewFile! !

Block Importer License

1. You are free to use this feature in any mod but you must give credit to me, dreamod, and NXIII, and you may in no way imply that this is your work. This patch is a modification based off of one of NXIII's works.

2. You may in no way imply that this is your work.

3. I will not take any responsibility for any impacts on any modified version of scratch including Panther, BYOB, or Slash, if this patch is installed. If you wish to avoid any unwanted changes, view the patch and modify parts to fit your mod.

4. If you install the patch included in this folder, and use it in your mod , then you must also give credit to dreamod and NXIII. It may be used in any way.

5. Enjoy and please provide feedback on this forum:
http://scratch.mit.edu/forums/viewtopic.php?id=91639

Download patch here: http://www.mediafire.com/?rjm3uj39wr3fuok

Please comment and tell me how I can improve it.

Offline

 

#65 2012-03-19 17:13:13

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Developing BLOCK files.

maybe it should be formatted like xml:

Code:

<blocks>
  <block category=(block category) location=(location in system browser)>
    <spec>(blockspec)</spec>
    <code>
      (block code)
    </code>
  </block>
  ...
<blocks>

DTD:

Code:

<!DOCTYPE blocks[
<!ELEMENT blocks (block*)>
<!ELEMENT block (spec, code)>
<!ATTLIST block category (motion|control|looks|sensing|sound|operators|pen|variables) #REQUIRED>
<!ATTLIST block location cdata #REQUIRED>
<!ELEMENT spec (#PCDATA)>
<!ELEMENT code (#CDATA)>

Last edited by joefarebrother (2012-03-23 14:06:17)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#66 2012-07-05 11:19:55

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

Re: Developing BLOCK files.

I have a .BLOCK file that i'm working on!


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

Offline

 

#67 2012-07-06 07:11:45

spkshark
Scratcher
Registered: 2011-03-05
Posts: 65

Re: Developing BLOCK files.

I'll help! But i'm not so good at this sort of stuff but i'll give it a go!


http://d2bm3ljpacyxu8.cloudfront.net/width/300/crop/0,0,300x145/spkshark.webs.com/scratch%20script.gif

Offline

 

#68 2012-07-06 07:20:42

spkshark
Scratcher
Registered: 2011-03-05
Posts: 65

Re: Developing BLOCK files.

How do I make the file?


http://d2bm3ljpacyxu8.cloudfront.net/width/300/crop/0,0,300x145/spkshark.webs.com/scratch%20script.gif

Offline

 

#69 2012-07-06 11:54:57

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Developing BLOCK files.

You can try the block importer. It can create, export, import and do lots of more stuff with block and block files: http://www.mediafire.com/?bjdyg9wd965onla

Offline

 

#70 2012-07-07 09:25:21

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

Re: Developing BLOCK files.

what if you added export and create blocks in the block importer patch to help write and read .BLOCK files!


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

Offline

 

#71 2012-07-08 09:36:23

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Developing BLOCK files.

PopTarties wrote:

what if you added export and create blocks in the block importer patch to help write and read .BLOCK files!

I already have.

Offline

 

#72 2012-07-20 16:06:15

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

Re: Developing BLOCK files.

http://scratch.mit.edu/forums/viewtopic.php?id=102052


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

Offline

 

#73 2012-09-03 21:11:29

PencilFactory
Scratcher
Registered: 2011-11-11
Posts: 100+

Re: Developing BLOCK files.

I’ll help
I know how to make blocks for scratch

Last edited by PencilFactory (2012-09-03 21:13:42)


PencilFactory is http://blocks.scratchr.org/API.php?user=PencilFactory&amp;action=onlineStatus&amp;type=text, see my computerhttp://mag.racked.eu/cimage/i9002/Achievement+get%21/Computer+crashed/mca.png

Offline

 

#74 2012-09-28 22:50:49

PencilFactory
Scratcher
Registered: 2011-11-11
Posts: 100+

Re: Developing BLOCK files.

control
spec:

(‘Press green flag’ #- #PressGreenFlag)

code:

pressGreenFlag
    self broadcast: 'Scratch-StartClicked' withArgument: 0

how do I make that into a block file?


PencilFactory is http://blocks.scratchr.org/API.php?user=PencilFactory&amp;action=onlineStatus&amp;type=text, see my computerhttp://mag.racked.eu/cimage/i9002/Achievement+get%21/Computer+crashed/mca.png

Offline

 

#75 2012-09-29 04:26:56

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Developing BLOCK files.

PencilFactory wrote:

control
spec:

(‘Press green flag’ #- #PressGreenFlag)

code:

pressGreenFlag
    self broadcast: 'Scratch-StartClicked' withArgument: 0

how do I make that into a block file?

try my block importer here http://www.mediafire.com/?bjdyg9wd965onla
it can help you create block files.
you go to Blocks and select 'create block'

Offline

 

Board footer