标题: scope 觀念 + void setup and void draw [打印本页] 作者: weiwei 时间: 2010-10-15 16:16 标题: scope 觀念 + void setup and void draw [attach]11688[/attach]
Each program can have only one setup() and one draw(). When the program starts, the code outside of setup() and draw() is run. Next, the code inside the setup() block is run once. After that, the code inside the draw() block is run continuously until the program is stopped.Because the variable y is declared outside of setup() and draw(), it’s a global variable and can be accessed and assigned anywhere within the program.
[attach]11689[/attach]
Variables declared within setup() can be accessed only within the setup() block. Variables declared within draw() can be accessed only within the draw() block. The scope of a variable declared within a block,called a local variable, extends only to the end of the block.
[attach]11690[/attach]
When a variable is created within a block, it is destroyed when the program leaves the block. For example, if a new variable is created inside an if block, it can be used within but cannot be accessed outside the block. If a new variable is used to iterate through a for structure, it can be used within but cannot be accessed outside the block.作者: weiwei 时间: 2010-10-15 16:17
一些基本的概念...老實說看手冊就懂了,我也不知道為什麼還要發這個帖..作者: weiwei 时间: 2010-10-15 16:25
補充一下:可以重複命名的好處
Variable scope makes it possible to have more than one variable in a program with the
same name. It’s common to use the same variable name for iterating over multiple for
structures in one program, but in general, having more than one variable with the same
name is not recommended.作者: skywoolf 时间: 2010-10-15 16:36
支持了~我想这样的讲解多了可以促进大家的交流氛围~wei辛苦了!作者: weiwei 时间: 2010-10-15 16:39
恩 ! 晚點再發個function 的概念 一個好用的方法!!作者: STL2000 时间: 2010-10-16 00:53
好的,谢谢了!作者: lliiuushuai 时间: 2010-10-22 10:35
受用了。。学习作者: duncanrock110 时间: 2010-10-31 18:56
很不错的东东哦作者: lbai4697 时间: 2011-5-17 08:42
不错
up到前面作者: 时间敲冰 时间: 2011-5-22 14:46
谢谢,楼主继续啊,最近在学processing,一些基本的概念就是缺乏,这样讲解就更清楚了。作者: bxsqrym 时间: 2011-5-24 13:56
泪奔~~~泪奔作者: ping88 时间: 2011-5-24 14:43
学processing,一些基本的概念就是缺乏作者: 龙龙 时间: 2011-5-29 07:44
fffffffffffffffffffffffffffffffffff作者: axo001 时间: 2012-3-14 14:02
定~~~~~~~~~~~~~~~~作者: axo001 时间: 2012-3-14 14:03
支持!~~~~~~~~~~~~~~~作者: FRICKKJ 时间: 2012-3-15 00:54
支持!!!!