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

#1 2010-02-16 12:33:51

shsh
Scratcher
Registered: 2010-02-16
Posts: 1

Help with IF

I wrote a most basic logic block. However, to my frustration, it just doesn't work.

http://scratch.mit.edu/projects/shsh/890805

Here is the script:

Define a variable a,
Set a to 1
If a=1
  increase a by 1
else
  increase a by 3
endif

To my amazement, the else block is always executed, but not the if block.

Could somebody figure this out and tell me why?

Thanks,

Offline

 

#2 2010-02-16 14:29:49

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

Re: Help with IF

I see what the problem is.

This is your script right now:
http://www.freeimagehosting.net/uploads/a764343090.gif

In scratch, to test a variable in an = block you have to go to the variables section, drag out the round block with the name of the variable (in this case, "a") and drop it into the left side. Typing the name of the variable doesn't work.

The new script should look like this:
http://www.freeimagehosting.net/uploads/c4b63659fb.gif

Also, you don't need the "show variable" block. That's just to show/hide the variable on-screen, and since it's already showing, it's not really doing anything.  smile

Last edited by hmnwilson (2010-02-16 14:35:34)


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

 

#3 2010-02-16 17:19:34

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

Re: Help with IF

Actually, the variable may hide somewhere in between.

Are you hiding and showing the variable?


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

Offline

 

#4 2010-02-16 17:42:01

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Help with IF

It's already resolved, the rest might be something he's doing on purpose.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

Board footer