Tcl -- variable
2016-04-06 21:10
309 查看
1. variable - create and initialize a namespace variable
用于在名字空间里创建和初始化变量。
2. 语法
variable ?name value...? name ?value?
3. 说明
This command is normally used within a namespace eval command to create one or more variables within a namespace.
Each variable name isinitialized with value. The value for
thelast variable is optional. 最后一个变量的值是可选的。
If a variable name does not exist, it is created. In this case, if value is specified, it is assigned to the newly
created variable.
如果变量名不存在,则创建该变量。如果指定了value,则将该value赋值给variable.
If no value is specified, the new variable is left undefined. 如果没有指定value,可以在后续进行定义。
If the variable already exists, it is set to value if value is specified or left unchanged if no value is
given.
如果变量已经存在,如果有value,则将更改它的值为value值。如果没有value,则它之前的值保持不变。
If name includes any namespace qualifiers(其他名字空间的限定符), the variable is created in the specified namespace.
If the variable is not defined, it will be visible to the namespace which command, but not to the info
exists command.
A name argument cannot reference an element within an array.
(不应该用数组元素,而应该用数组名,随后用set或者array命令来定义该数组)
Instead, name should reference the entire array, and the initialization value should
be left off. (初始值先不管)
After the variable has been declared, elements within the array can be set using ordinary set or array commands.
4. 举例
1) 定义一个名字空间some,里面有一个数组day
2) 定义一个名字空间lion,里面有一个proc为fun,引用::some::day(some名字空间中的day数组)
3) 调用lion名字空间中的fun
用于在名字空间里创建和初始化变量。
2. 语法
variable ?name value...? name ?value?
3. 说明
This command is normally used within a namespace eval command to create one or more variables within a namespace.
Each variable name isinitialized with value. The value for
thelast variable is optional. 最后一个变量的值是可选的。
If a variable name does not exist, it is created. In this case, if value is specified, it is assigned to the newly
created variable.
如果变量名不存在,则创建该变量。如果指定了value,则将该value赋值给variable.
If no value is specified, the new variable is left undefined. 如果没有指定value,可以在后续进行定义。
If the variable already exists, it is set to value if value is specified or left unchanged if no value is
given.
如果变量已经存在,如果有value,则将更改它的值为value值。如果没有value,则它之前的值保持不变。
If name includes any namespace qualifiers(其他名字空间的限定符), the variable is created in the specified namespace.
If the variable is not defined, it will be visible to the namespace which command, but not to the info
exists command.
A name argument cannot reference an element within an array.
(不应该用数组元素,而应该用数组名,随后用set或者array命令来定义该数组)
Instead, name should reference the entire array, and the initialization value should
be left off. (初始值先不管)
After the variable has been declared, elements within the array can be set using ordinary set or array commands.
4. 举例
1) 定义一个名字空间some,里面有一个数组day
2) 定义一个名字空间lion,里面有一个proc为fun,引用::some::day(some名字空间中的day数组)
3) 调用lion名字空间中的fun
相关文章推荐
- Cross-Browser Variable Opacity with PNG
- PHP提示Notice: Undefined variable的解决办法
- 深入理解JavaScript系列(12) 变量对象(Variable Object)
- php Undefined index和Undefined variable的解决方法
- 深入理解PHP原理之变量生命期(一)
- JBPM学习(五):流程变量
- 多个Market共用一个InfoWindow
- Environment variable in Mac OS X
- Static Variable, Auto Variable, Global Variable, Local Variable, Register Variable (C)
- nginx 变量 获取 ngx_http_script_run 详解
- python main函数中变量默认为global variable
- Local declaration of 'XXX' hides instance variable
- Local Variables
- shell变量
- JavaScript Variable Gotchas
- How to find variable is empty in shell script
- Machine Learning week 1 quiz: Linear Regression with One Variable
- Ruby Variable Scope 简单讲解
- Linux---shell(1)
- 小战Java笔记_SE_Variable(变量)