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

#1 2010-03-07 08:25:10

scratchboard
Scratcher
Registered: 2010-03-02
Posts: 4

While:

I cannot find any way of doing a ''While'' function. Someone reccomended that I do a ''Repeat Forever if [_]'' however with sounds this just repeats the sound, (say a note) rather than playing the sound continuously! I want a way of doing, eg. ''While [A] pressed, play note [31]''



<forever if><key[A]pressed?>
<end>

Offline

 

#2 2010-03-07 08:53:46

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: While:

Does this help?

<when green flag clicked>
<forever>
<repeat until><key[ a ]pressed?>
<play note( 31 )for( Number... )secs>
<end>
<end>

Offline

 

#3 2010-03-07 10:11:29

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: While:

I don't think that's possible.


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#4 2010-03-07 14:16:18

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: While:

scratchboard -
I assume that by a while loop you mean a cblock that does the code inside while the condition (boolean) is true. To accomplish this, one must note that a the repeat until block has a very similar function: it does the code inside until the condition is true. It is the exact opposite. So, using that information, we know that a while block is really just this:
[blocks]
<repeat until> <not> condition   >>
Do something...
<end>
[/blocks]

Last edited by nXIII (2010-03-07 14:17:33)


nXIII

Offline

 

Board footer