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

#1 2011-01-29 13:57:16

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

How does a block read another category's variables?

You don't need help figuring out what I want.

Offline

 

#2 2011-01-29 13:58:53

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: How does a block read another category's variables?

Same way VB and C++ do it.

PUBLIC variables.


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#3 2011-01-29 14:03:34

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How does a block read another category's variables?

Except it is already defined as private. I am trying to make a block that mirrors the shift-click-R menu.

Offline

 

#4 2011-01-29 14:29:55

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: How does a block read another category's variables?

self reportVar: 'variable name"

or self readVar: 'variable name'

I can't remember which.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#5 2011-01-30 03:32:14

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How does a block read another category's variables?

it looks like readVar but it's not working.

Offline

 

#6 2011-01-30 05:02:03

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: How does a block read another category's variables?

|t1|
t1_ self readVar:'global scratch variable name'.
^ t1

_____________________________________-
line 1 declares the variable t1
line 2 sets the variable t1 to the global variable "global scratch variable name". (remember the single speech marks ( ' not " ) and the period at the end of the line.
the last line reports the variable t1. If you make the block a reporter, you should get it reporting the value of the global variable! Voila!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#7 2011-01-30 09:19:00

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How does a block read another category's variables?

Can it only see public variables? I want to make one that tells whether fill screen is on or off.

Offline

 

#8 2011-01-30 12:16:00

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: How does a block read another category's variables?

No idea. there probably is a way, but I don't know...


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

Board footer