Dazachi wrote:
I'm still kinda confused. How can I set a variable just for my block?
I can think of two possible meanings for your question, so I'm going to answer both of them.
(1) How can I have a variable just inside my block to hold information temporarily while the block is running?
Answer: While editing your block, look near the top of the Variables menu for the dark grey "Script Variables" block. Drag it into your block's script. It comes with a variable named "a" but you can click on that name to change it to something else. Then you can use the regular variable mechanisms like SET and CHANGE with it, **but only when the SET or CHANGE block is actually attached to your script** not just hanging loose in the block editor. And you can drag the variable name out of the Script Variables block into whatever block needs to see the value.
(2) How can I have a variable that retains its value even when my block isn't running, but is visible only inside my block?
Answer: This can be done, but it's more complicated.
Let's say you want your block to be called MYBLK. Don't make a block MYBLK! Instead, make a *variable* (sprite or global as desired) named MYBLK, and then make a block MAKE-MYBLK, a command, that contains
Script Variables <var>
SET <var> TO <start-value>
SET <MYBLK> TO [THE SCRIPT ......]
where you put whatever your block should do inside the THE SCRIPT block. Then just run MAKE-MYBLK. Now, when you want to use your block, you have to say
RUN <MYBLK>
(or CALL if it's a reporter/predicate).
If neither of these is what you meant, please try asking in more detail. Thanks.
Offline
bharvey wrote:
Dazachi wrote:
I'm still kinda confused. How can I set a variable just for my block?
I can think of two possible meanings for your question, so I'm going to answer both of them.
(1) How can I have a variable just inside my block to hold information temporarily while the block is running?
Answer: While editing your block, look near the top of the Variables menu for the dark grey "Script Variables" block. Drag it into your block's script. It comes with a variable named "a" but you can click on that name to change it to something else. Then you can use the regular variable mechanisms like SET and CHANGE with it, **but only when the SET or CHANGE block is actually attached to your script** not just hanging loose in the block editor. And you can drag the variable name out of the Script Variables block into whatever block needs to see the value.
(2) How can I have a variable that retains its value even when my block isn't running, but is visible only inside my block?
Answer: This can be done, but it's more complicated.
Let's say you want your block to be called MYBLK. Don't make a block MYBLK! Instead, make a *variable* (sprite or global as desired) named MYBLK, and then make a block MAKE-MYBLK, a command, that contains
Script Variables <var>
SET <var> TO <start-value>
SET <MYBLK> TO [THE SCRIPT ......]
where you put whatever your block should do inside the THE SCRIPT block. Then just run MAKE-MYBLK. Now, when you want to use your block, you have to say
RUN <MYBLK>
(or CALL if it's a reporter/predicate).
If neither of these is what you meant, please try asking in more detail. Thanks.
Thank you! The first one is the one I wanted. Now my blocks work!
Offline
bharvey wrote:
Okay, I give up, clearly you need help with this...
http://cs.berkeley.edu/~bh/lamgobo.gif
What?
Offline
bharvey wrote:
Okay, I give up, clearly you need help with this...
http://cs.berkeley.edu/~bh/lamgobo.gif
I can't find anything that resembles that on a (almost) complete list of mathematical symbols. Maybe someone else will have more luck than I....
EDIT: It looks kinda like the Greek lambda, but that doesn't make a whole lot of sense.
Last edited by shadow_7283 (2010-05-01 09:58:47)
Offline
shadow_7283 wrote:
bharvey wrote:
Okay, I give up, clearly you need help with this...
http://cs.berkeley.edu/~bh/lamgobo.gifI can't find anything that resembles that on a (almost) complete list of mathematical symbols. Maybe someone else will have more luck than I....
EDIT: It looks kinda like the Greek lambda, but that doesn't make a whole lot of sense.
http://upload.wikimedia.org/wikipedia/c … da.svg.png
Yes it does.... You know how in the trailer it says
Scratch4cs = Scratch
(+ BYOB + λ)
meaning you can make your own blocks and use lambda programming.
Offline
nXIII wrote:
shadow_7283 wrote:
bharvey wrote:
Okay, I give up, clearly you need help with this...
http://cs.berkeley.edu/~bh/lamgobo.gifI can't find anything that resembles that on a (almost) complete list of mathematical symbols. Maybe someone else will have more luck than I....
EDIT: It looks kinda like the Greek lambda, but that doesn't make a whole lot of sense.
http://upload.wikimedia.org/wikipedia/c … da.svg.pngYes it does.... You know how in the trailer it says
Scratch4cs = Scratch
(+ BYOB + λ)meaning you can make your own blocks and use lambda programming.
Exactly... at first, I thought that extra thing on Gobo was some kind of greek letter.
I made a beta tag... you can use it if you want.
Offline
shadow_7283 wrote:
looks kinda like
Anyone who's a better artist than I is welcome to contribute an improved version. But everyone at Berkeley (where we use SICP in our first computer science course) got it right away! (Of course they also have the advantage of knowing what a fanatic I am about first-class functions -- but so do you, given the movie!)
Last edited by bharvey (2010-05-01 11:36:37)
Offline
nXIII wrote:
shadow_7283 wrote:
bharvey wrote:
Okay, I give up, clearly you need help with this...
http://cs.berkeley.edu/~bh/lamgobo.gifI can't find anything that resembles that on a (almost) complete list of mathematical symbols. Maybe someone else will have more luck than I....
EDIT: It looks kinda like the Greek lambda, but that doesn't make a whole lot of sense.
http://upload.wikimedia.org/wikipedia/c … da.svg.pngYes it does.... You know how in the trailer it says
Scratch4cs = Scratch
(+ BYOB + λ)meaning you can make your own blocks and use lambda programming.
Cool!
Offline
I am pleased to announce that Tutorial 2: Lists and Higher Order Functions is finally done! It's on the Scratch site in three(!!!) parts, starting with http://scratch.mit.edu/projects/bharvey/1021777. I'm really hoping that at least some of you will find it as life-changing as it was when I learned about functional programming!
Offline
bharvey wrote:
Okay, I guess you're right, maybe this one is better?
http://cs.berkeley.edu/~bh/gobol3.gif
That is cool!
Offline
bharvey wrote:
Okay, I guess you're right, maybe this one is better?
http://cs.berkeley.edu/~bh/gobol3.gif
It still looks very rough.
Firstly, don't use black - use the gobo's grey border color. And make sure the thickness of the border is the same all the way around, and it's smooth.
Offline
Lucario621 wrote:
bharvey wrote:
Okay, I guess you're right, maybe this one is better?
http://cs.berkeley.edu/~bh/gobol3.gifIt still looks very rough.
Firstly, don't use black - use the gobo's grey border color. And make sure the thickness of the border is the same all the way around, and it's smooth.
But I don't think the normal Gobo's border is the same thickness all the way around
Offline
nXIII wrote:
Lucario621 wrote:
bharvey wrote:
Okay, I guess you're right, maybe this one is better?
http://cs.berkeley.edu/~bh/gobol3.gifIt still looks very rough.
Firstly, don't use black - use the gobo's grey border color. And make sure the thickness of the border is the same all the way around, and it's smooth.But I don't think the normal Gobo's border is the same thickness all the way around
Well, for the most part, at least.
Offline
Jens - back to my chord block idea on the third page of this thread (assuming you have the default amount of posts per page)
What type of input types should the different inputs be? They could be any, or possibly text, I really don't know.
Secondly (and more importantly), I can I have the script play the multiple notes at the same time? Perhaps, if it is possible, could the block broadcast messages just to other scripts within the block definition? That might work - if you have that implemented.
Offline
I found another glitch.
If you put a rounded reporter block into a boolean block, such as the ones in the picture, then take it out it makes it only allow you to enter numbers (Or intergers) and no text (Or strings)
Offline
In addition (to my previous post), by looking at my script on page 3, within each of the else part of the if else blocks, should I have a stop block afterwards? Or is it not necessary?
Offline
Is it possible to remove a variable from a block definition? Because I'm not able to...
Offline
I decided to change the note and octave to just note (as in midi note). What is the range of midi notes on Scratch, for an actual keyboard? I think it's 21 (the lowest A) to 108 (the highest C) - but I might be wrong (I mean, doesn't that make 87 keys lol?).
Offline
bharvey wrote:
Picky, picky.
http://cs.berkeley.edu/~bh/gobol3.gif
TBH, that's great! A lot better! That's overall what I wanted
Now I COULD complain some more about having you dither it a bit more, but I can tell you're not exactly the 'graphics' person, if you know what I mean
Should I replace the picture of Gobo on the first post with this new one?
Last edited by Lucario621 (2010-05-02 13:42:31)
Offline
I think iv got it now!
What doy uo think of my one?
Last edited by markyparky56 (2010-05-02 13:53:53)
Offline
Lucario621 wrote:
What type of input types should the different inputs be? They could be any, or possibly text, I really don't know.
I'm not Jens, and not a musician, so I'm going to leave most of this for him to answer. But I can respond to this part. There is actually no difference between Any and Text except for the shape of the slot, so just use whatever looks right to you.
Lucario621 wrote:
In addition (to my previous post), by looking at my script on page 3, within each of the else part of the if else blocks, should I have a stop block afterwards? Or is it not necessary?
Not necessary, unless there's more code below the whole thing that you want to avoid.
We should, by the way, have a multiway test block so people don't have to nest IFs like that. I'm waiting for Jens to invent the notation to make a /group/ of inputs variadic, so I can write a block like
IF <boolean> THEN <C-slot> { ELSE IF <boolean> THEN <C-slot> }... ELSE <C-slot>
Offline
markyparky56 wrote:
I think iv got it now!
What doy uo think of my one?
That's cool markyparky56 - but do you understand why in Gobo's image, Gobo looked that way? It's not just for decoration - it's because it's supposed to look like this:
meaning you can make your own blocks and use lambda programming.
Yours doesn't look like that at all, so that would ruin the purpose of the new gobo
Offline