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

#1 2009-10-23 23:55:15

penlu
Scratcher
Registered: 2009-07-22
Posts: 5

Functions

I think that not being able to have functions with arguments can be limiting sometimes.  The message thing helps a bit, but you can't attach any arguments to it.  There should be a block that has something like "send message ___ with notes ___, ___, ___".  The receiving end would be "when I receive message ___ and ___, ___, ___" or something.  I don't know how to work with the returned value.  You could work around this by using variables to store arguments and then sending a message and having the thing receiving the message change the variables.  This is kind of time-consuming, though.  It would be much easier to just type stuff into a block.

Offline

 

#2 2009-10-24 02:52:16

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Functions

Using lists can make this happen this right now try , the join length etc and the list and variable blocks can be added in the broadcast function then u can simply type the output or use again the same method for the output


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#3 2009-10-24 20:55:34

penlu
Scratcher
Registered: 2009-07-22
Posts: 5

Re: Functions

WHOA.  I didn't know that!  Thanks!  smile

Offline

 

#4 2009-10-27 18:30:10

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Functions

OR you could do this:
[blocks]
main script
<set{  argument1  }to(  4  )>
<set{  argument2  }to(  4  )>
<broadcast[  myfunction  ]and wait c>

function
<when I receive[  myfunction  }>
(use variables argument1 and 2)

Once the function is done, the main script is done. In this way you can pretend to have functions and arguments/parameters.
[/blocks]


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#5 2009-10-31 18:38:34

penlu
Scratcher
Registered: 2009-07-22
Posts: 5

Re: Functions

Yeah, that's the idea I had.  But it's kind of inconvenient in that you have to create more variables and stuff.

Offline

 

#6 2009-10-31 19:05:14

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Functions

You can just use a list.


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#7 2009-11-01 12:15:03

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Functions

Yes. Lists help a lot. Try it!


Hai.

Offline

 

#8 2009-11-01 15:37:35

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Functions

Yeah, other languages have lists, but they also have user defined functions, so lists don't make functions obsolete. Adding functions would save a ton of time and be better practise for real programming.

Last edited by archmage (2009-11-01 15:38:05)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#9 2009-11-03 01:48:55

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Functions

By other languages, I think you meant arrays...


Hai.

Offline

 

#10 2009-11-03 10:25:27

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Functions

Lists and arrays are the same thing. Scratch just like to put things into simple terms.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

Board footer