Tcl -- variable

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

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值