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

#1 2007-03-08 12:28:45

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

Feature request: Create subroutines

When I fill a control block, I often want to re-use it elsewhere.  It would be nice to be able to create new blocks based on a filled block.

Offline

 

#2 2007-03-08 23:10:46

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

Re: Feature request: Create subroutines

Hi, Deiza.

Good suggestion. For a future version, we are considering adding the ability to define your own new blocks. There are many details to work out, such as how to specify parameters and how to make clear the different between writing a normal script vs. defining a new block, and so on. But procedural abstraction is a fundamental computer science idea and it would be nice to be able to demonstrate it within Scratch.

  -- John

Offline

 

#3 2007-03-09 04:15:45

patarakin
Scratcher
Registered: 2007-03-07
Posts: 5

Re: Feature request: Create subroutines

May be it will be possible to use same the blocks in different plojects?

Offline

 

#4 2007-03-09 05:15:53

shadowfirebird
Scratcher
Registered: 2007-03-09
Posts: 3

Re: Feature request: Create subroutines

I agree that subroutines would be nice, but you can sort of do it with broadcasting and variables.

Offline

 

#5 2007-03-09 22:56:26

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

Re: Feature request: Create subroutines

patarakin wrote:

May be it will be possible to use same the blocks in different plojects?

I agree, there should be a way to copy a block definintion from one project to another. We'll have to figure a good way to do that. (E.g. block definitions might be attached to exported sprites.)

Thanks for pointing out the need for this...

  -- John

Last edited by johnm (2007-03-09 22:56:51)

Offline

 

#6 2007-03-10 20:46:25

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

Re: Feature request: Create subroutines

Thanks for the replies.  I was thinking that to make a re-usable block, there could be a couple of different control blocks, one plain, one which has a variable slot, one which has a condition slot.  Very similar to how the loops are, except that, like "Make a variable" you get to pick a name and it creates a new block.  The new block is then a placeholder for whatever is in the original block, but keeps your program smaller and easier to read.  This wouldn't cover everything possible in subroutines, but would be a nice balance between power and usability (I think).

Great job, my kids are loving Scratch.

Offline

 

#7 2007-03-11 22:39:49

jay
Scratch Team
Registered: 2007-03-11
Posts: 59

Re: Feature request: Create subroutines

On the note of using "broadcast" for making your own subroutines, it is possible to name a subroutine "broadcast" and then export the sprite which contains the "subroutine" (broadcast stack). Then in a new project you can import the sprite, and the "subroutine" will come with it. Note: Export sprite is above the Scripts panel, and import sprite is under the "extras" menu.

Offline

 

#8 2007-03-12 21:55:10

altamiro
Scratcher
Registered: 2007-03-12
Posts: 2

Re: Feature request: Create subroutines

johnm wrote:

patarakin wrote:

May be it will be possible to use same the blocks in different plojects?

I agree, there should be a way to copy a block definintion from one project to another. We'll have to figure a good way to do that. (E.g. block definitions might be attached to exported sprites.)

Thanks for pointing out the need for this...

  -- John

Yes this would introduce non programmers to Scratch as we (building up user community) could provide a library or repository of classical algorithms such as different sorting algorithms or motion algorithms.

This may also create a distance of kids from basic programming that was what made me interested in Scratch in the first place, reminding-me of the good old days of problem solving programming with the Timex ZXSpectrum in the 80'es.

So improve Scratch without loosing the focus on: "simple basic programming tool"
;-)

Altamiro

Offline

 

#9 2007-03-20 18:17:48

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

Re: Feature request: Create subroutines

Hi, Altamiro.

Re: So improve Scratch without loosing the focus on: "simple basic programming tool"

I fully agree!

  -- John

Offline

 

#10 2007-04-16 21:30:41

Vanslar
Scratcher
Registered: 2007-03-17
Posts: 100+

Re: Feature request: Create subroutines

i think a "when..." block would be nice.


  I am a royal pain in the butt, I am ~Vanslar~       
      Want better gravity? Go to
Realistic Gravity, By Vanslar 2-D
Want a better way to spend your spare time? CubeField

Offline

 

#11 2010-01-17 09:55:09

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Feature request: Create subroutines

Vanslar wrote:

i think a "when..." block would be nice.

Easy. Close Scratch (ScratchFrameMorph). In the browser (World, open..., browser), where in class the 'blockSpecs' (Scratch-Objects, ScriptableScratchMorph, scratch) go to that.
Now, after ('when %m clicked' #M #-) , put ('when %b is true' #W #-) and restart scratch, tada!
If you need help, please reply.

Offline

 

#12 2010-01-17 13:59:56

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: Feature request: Create subroutines

rdococ wrote:

Vanslar wrote:

i think a "when..." block would be nice.

Easy. Close Scratch (ScratchFrameMorph). In the browser (World, open..., browser), where in class the 'blockSpecs' (Scratch-Objects, ScriptableScratchMorph, scratch) go to that.
Now, after ('when %m clicked' #M #-) , put ('when %b is true' #W #-) and restart scratch, tada!
If you need help, please reply.

You realize there haven't been any replies in this topic since april 2007, right?


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#13 2010-03-11 20:59:29

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Feature request: Create subroutines

rdococ wrote:

Vanslar wrote:

i think a "when..." block would be nice.

Easy. Close Scratch (ScratchFrameMorph). In the browser (World, open..., browser), where in class the 'blockSpecs' (Scratch-Objects, ScriptableScratchMorph, scratch) go to that.
Now, after ('when %m clicked' #M #-) , put ('when %b is true' #W #-) and restart scratch, tada!
If you need help, please reply.

I did, and it didn't work.

Offline

 

Board footer