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

#1 2010-04-04 11:42:43

WubbGmbaa
Scratcher
Registered: 2009-05-30
Posts: 7

forever if else block

There's an if block:

<if>
<end>

There's an if / else block:
<if>

<else>
<end>

There's a forever if block:
<forever if>
<end>

How about a forever if / else block?
<forever if>

<else>
<end>

Offline

 

#2 2010-04-04 12:56:31

midnightleopard
Scratcher
Registered: 2007-09-13
Posts: 1000+

Re: forever if else block

good idea but why don't you just
[blocks]
<forever>
<if>
<else>
<end>


http://pwp.wizards.com/5103673563/Scorecards/Landscape.png

Offline

 

#3 2010-04-04 13:14:05

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: forever if else block

He just simplifying it, just like

<forever if>
<end>

is

<forever>
<if>
<end>
<end>
[/blocks]

If they made forever if, then they should make this.

Last edited by Kingdaro (2010-04-04 13:15:10)

Offline

 

#4 2010-04-04 15:21:49

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: forever if else block

Yes, but since you can already do it it's not that necessary.


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#5 2010-04-04 15:45:37

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: forever if else block

Was the Forever If block necessary?

Offline

 

#6 2010-04-04 16:36:40

frogger3140
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: forever if else block

No, it isn't


http://j.mp/piBfFy
Woo, even better minecraft clone! | I feel that programming is better than animation, because you can interact with games but not animations.

Offline

 

#7 2010-04-04 17:07:23

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

Re: forever if else block

I never use the forever if block. It's really pointless.


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

 

#8 2010-04-04 19:32:44

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: forever if else block

The 'forever if' block is so stupid that BoltBait suggested it to be removed - and we got a big wave of supporters.

The 'forever if else' block is just as silly, sorry.  sad


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#9 2010-04-05 05:19:11

Phi_Lho
Scratcher
Registered: 2010-03-22
Posts: 75

Re: forever if else block

Forever if is similar to a while () loop in other languages. It is not really pointless, it avoids a nesting level... (although, looking better, it seems to be duplicate in functionality with repeat until, just inverting the condition).

I just don't see the point of a forever if / else, when it is supposed to go in the else part? If the condition is no longer satisfied, it just goes out of the loop and continue below.

break (getting out of the loop and continuing with the remainder of the script) and continue (skipping remainder of the loop content to go to next loop start) blocks might be useful, though.


http://i241.photobucket.com/albums/ff159/PhiLho/KM150.pnghttp://i241.photobucket.com/albums/ff159/PhiLho/PhiLhoLogo.png

Offline

 

#10 2010-04-05 09:01:43

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: forever if else block

Phi_Lho wrote:

Forever if is similar to a while () loop in other languages.

I thought that was the "repeat until" block.  hmm  (EDIT: Nvm you're right.  tongue )

Break and continue would be really useful, I agree.  smile

Last edited by technoguyx (2010-04-08 21:12:30)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#11 2010-04-05 10:35:12

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: forever if else block

For ever if is made because they first had a "When < >" hat, but they didn't like it for some reason. It is replaced by 'forever if < >' which is indeed a waste of space in the blocks library  wink


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#12 2010-04-05 15:14:55

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: forever if else block

I still support tho.  smile

Offline

 

#13 2010-04-08 18:49:03

--test_account--
Scratcher
Registered: 2010-04-02
Posts: 2

Re: forever if else block

We don't really need the if else block either. You can create that with If <insert>do (blah)
If <not<insert>> do (blah)

cool

Offline

 

#14 2010-04-08 21:14:19

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: forever if else block

--test_account-- wrote:

We don't really need the if else block either. You can create that with If <insert>do (blah)
If <not<insert>> do (blah)

cool

Yes, but we have the if/else block for simplicity. Nearly any programming language lets you use "else" statements too.

And if the Scratch Team removed it for some reason, over half of the projects uploaded would be obsolete, same if they removed the forever if block.

Last edited by technoguyx (2010-04-08 21:15:19)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#15 2010-04-08 21:31:39

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

Re: forever if else block

technoguyx wrote:

And if the Scratch Team removed it for some reason, over half of the projects uploaded would be obsolete, same if they removed the forever if block.

Nope, it would just become an obsolete block. It would turn red but still work, even though it doesn't exist anymore. Blocks like <abs( [/blocks] that have been removed still work in later versions.


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

 

#16 2010-04-08 23:52:15

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: forever if else block

hmnwilson wrote:

technoguyx wrote:

And if the Scratch Team removed it for some reason, over half of the projects uploaded would be obsolete, same if they removed the forever if block.

Nope, it would just become an obsolete block. It would turn red but still work, even though it doesn't exist anymore. Blocks like <abs( [/blocks] that have been removed still work in later versions.

But they won't work online if the java player is updated too (IIRC, blocks that are now obsolete only work offline...).


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#17 2010-04-09 01:48:00

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: forever if else block

technoguyx wrote:

hmnwilson wrote:

technoguyx wrote:

And if the Scratch Team removed it for some reason, over half of the projects uploaded would be obsolete, same if they removed the forever if block.

Nope, it would just become an obsolete block. It would turn red but still work, even though it doesn't exist anymore. Blocks like <abs( [/blocks] that have been removed still work in later versions.

But they won't work online if the java player is updated too (IIRC, blocks that are now obsolete only work offline...).

The Scratch Team isn't stupid... in Scratch 2.0, they'll probably keep the functionality for the obsolete blocks.


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#18 2010-04-09 01:54:25

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: forever if else block

Jonathanpb wrote:

The Scratch Team isn't stupid...

You're always contradicting that.  tongue


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#19 2010-04-09 01:55:30

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: forever if else block

Chrischb wrote:

Jonathanpb wrote:

The Scratch Team isn't stupid...

You're always contradicting that.  tongue

lol

Last edited by Jonathanpb (2010-04-09 01:56:37)


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#20 2010-11-18 14:56:20

axorion
Scratcher
Registered: 2010-01-05
Posts: 28

Re: forever if else block

First about the topic, forever if else: I don't think forever if is needed so forever if else would be more of the same uselessness.

--test_account-- wrote:

We don't really need the if else block either. You can create that with If <insert>do (blah)
If <not<insert>> do (blah)

cool

Your statement if false!

Code:

If x=1
   set x=2
else
   set x=3

Is not the same as...

Code:

if x=1
   set x=2
if not x=1
   set x=3

The second example using your method ends incorrectly with x always having the value 3 but the first example correctly gives x a value of 2 if it started with 1 and 3 if it started with any number other than 1. This is because your method evaluates x twice and x has changed since the first evaluation. The glory of if else is that it chooses between two blocks of code based on a single evaluation. Also, because your method requires two evaluations it will needlessly slow down your program.

Offline

 

#21 2010-11-18 16:26:39

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: forever if else block

axorion wrote:

First about the topic, forever if else: I don't think forever if is needed so forever if else would be more of the same uselessness.

--test_account-- wrote:

We don't really need the if else block either. You can create that with If <insert>do (blah)
If <not<insert>> do (blah)

cool

Your statement if false!

Code:

If x=1
   set x=2
else
   set x=3

Is not the same as...

Code:

if x=1
   set x=2
if not x=1
   set x=3

The second example using your method ends incorrectly with x always having the value 3 but the first example correctly gives x a value of 2 if it started with 1 and 3 if it started with any number other than 1. This is because your method evaluates x twice and x has changed since the first evaluation. The glory of if else is that it chooses between two blocks of code based on a single evaluation. Also, because your method requires two evaluations it will needlessly slow down your program.

Okay, but this thread is a bit old. (Check the date of the last post: April 9th.)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer