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

#1 2013-04-05 13:10:16

dakra137
New Scratcher
Registered: 2013-04-02
Posts: 3

Repeat Until - pretest vs post test

say [Hi]
repeat until <[1] = [2]>
say [Bye]
end
leaves "Bye" on the screen.  That means that the test happens after the action block executes, not before. 

In order to reflect this, shouldn't the repeat until C block have the until <    > test on the lower leg rather than the upper arm of the C ?

Code:

--- repeat ---
|
| say [Bye]
|
--- until < [1] = [2] >

Offline

 

#2 2013-04-05 13:17:37

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Repeat Until - pretest vs post test

The test is happening — your repeat block is looping forever!

The repeat until block loops until the boolean is true. As 1=2 is false, the block keeps looping forever. Try this:

say [Hi]
repeat until <[1] = [2]>
move (3) steps
end
See how the cat keeps moving?

You probably meant something like this:

say [Hi!]
repeat until <[1] = [1]>
say [Bye!]
end
...which leaves "Bye!" on the screen, as 1=1 is true, so the mouth of "repeat until 1=1" doesn't execute.

smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#3 2013-04-05 13:46:26

dakra137
New Scratcher
Registered: 2013-04-02
Posts: 3

Re: Repeat Until - pretest vs post test

woops.  My bad. Very embarrassing.
Thank you.

Offline

 

#4 2013-04-05 14:00:48

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Repeat Until - pretest vs post test

No problem!


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

Board footer