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

#1 2012-11-09 19:27:50

BernardUK
New Scratcher
Registered: 2012-11-09
Posts: 3

Variable initial value

New to Scratch, so a very simple query: In a downloaded project I find a variable shown in Viewer on Stage with a non-zero value. There are no Set blocks defining its value in the code, so where is it given its initial value? I have searched the wiki for the answer without success. Thanks.

Offline

 

#2 2012-11-09 20:07:32

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Variable initial value

Basically, Scratch saves the last known value of the variable. So if I were to pull out a Set [variable] to [5], click on it once (to run it), and then delete the block, the variable will still be the same. You can then save the project, upload it, and then download it and it'll still be [5]. Hopefully that explains it.  smile

Last edited by Magnie (2012-11-09 20:09:25)

Offline

 

#3 2012-11-10 10:39:44

BernardUK
New Scratcher
Registered: 2012-11-09
Posts: 3

Re: Variable initial value

Magnie wrote:

Basically, Scratch saves the last known value of the variable. So if I were to pull out a Set [variable] to [5], click on it once (to run it), and then delete the block, the variable will still be the same. You can then save the project, upload it, and then download it and it'll still be [5]. Hopefully that explains it.  smile

Aha! Thank you. smile x smile  That's now clear (and immediately demonstrable). I may surf the wiki once more to see whether there's really no mention of this feature in that part of the doc, and suggest a sentence if not...

Offline

 

Board footer