Tcl之looping
1 While loop
while test body
The while command evaluates test as an expression. If test is true, the code in body is executed. After body has been executed, test is evaluated again.
Example:
set x 1
# This is a normal way to write a Tcl while loop.
while {$x < 5} {
puts "x is $x"
set x [expr {$x + 1}]
}
puts "exited first loop with X equal to $x\n"
# The next example shows the difference between ".." and {...}
# How many times does the following loop run? Why does it not
# print on each pass?
set x 0
while "$x < 5" {
set x [expr {$x + 1}]
if {$x > 7} break
if "$x > 3" continue
puts "x is $x"
}
puts "exited second loop with X equal to $x"
2 For and incr
for start test next body
During evaluation of the for command, the start code is evaluated once, before any other arguments are evaluated. After the start code has been evaluated, the test is evaluated. If the test evaluates to true, then the body is evaluated, and finally, the next argument is evaluated. After evaluating the next argument, the interpreter loops back to the test, and repeats the process. If the test evaluates as false, then the loop will exit immediately.
incr varName ?increment?
This command adds the value in the second argument to the variable named in the first argument. If no value is given for the second argument, it defaults to 1.
Example:
for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}
for {set i 3} {$i < 2} {incr i} {
puts "I inside second loop: $i"
}
puts "Start"
set i 0
while {$i < 10} {
puts "I inside third loop: $i"
incr i
puts "I after incr: $i"
}
set i 0
incr i
# This is equivalent to:
set i [expr {$i + 1}]
Tcl之looping的更多相关文章
- Tcl internal variables
Tcl internal variables eryar@163.com 在Tcl中内置了一些变量,并赋予了一定的功能.内置变量列表如下: 变量名称 功能描述 argc 指命令行参数的个数. argv ...
- SDC Tcl package of Timequest
Tcl comand Tcl Commands all_clocks all_inputs all_outputs all_registers create_clock create_generate ...
- Oracle数据库操作分类DDL、DML、DCL、TCL类别清单异同
DDL Data Definition Language (DDL) statements are used to define the database structure or schema. S ...
- linux tcl expect 安装(转)
linux tcl expect 安装 一.Tcl安装 1. 下载:tcl8.4.20-src.tar.gz http://www.tcl.tk/software/tcltk/downloadnow ...
- 为Tcl编写C的扩展库
Tcl是一个比较简洁的脚本语言,官方地址 http://www.tcl.tk. tcl脚本加载C实现的动态库非常方便. 1. 为Tcl编写一个用C实现的扩展函数. #include <stdio ...
- Tcl
Tcl(发音 tickle)是一种脚本语言.由John Ousterhout创建.TCL经常被用于快速原型开发 RAD.脚本编程.GUI编程和测试等方面. Expect Expect是 另外一种非常流 ...
- MySQL TCL 整理
TCL(Transaction Control Language)事务控制语言SAVEPOINT 设置保存点ROLLBACK 回滚SET TRANSACTION
- TCL:使用、添加库文件
>直接引用工具自带的库文件 通过指令: .1查看能直接调用的库文件路径 #可以查到工具默认库文件路径,一般包括回显中的路径以及回显中路径的父路径. info library #D:/Script ...
- TCL:表格(xls)中写入数据
intToChar.tcl # input a number : 1 to 32 , you will get a char A to Z #A-Z:1-32 proc intToChar {int} ...
随机推荐
- hdu_1205_吃糖果_201404021440
吃糖果 Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submis ...
- Java实现打印功能-AWT Graphics2D
Java实现打印功能 用java实现打印,java.awt中提供了一些打印的API,要实现打印,首先要获得打印对象,然后继承Printable实现接口方法print,以便打印机进行打印,最后用用Gra ...
- android 视频开发2分之1(仿美拍,糗百)
近期比較忙,非常久没更新博客,今天我们仿一个美拍或者糗事百科的录像功能. 首先确认步奏: 1.打开摄像头: 2.開始录制: 3.支持分段录制,并支持分段删除: 4.把分段录制的视频进行合并: 不说废话 ...
- FloatingActionMenu 向上弹出菜单
本人在github上找到了一个FloatingActionsMenu,精简了其效果(原效果有上下左右四个方向)仅仅保留向上的效果,并做了一定的优化. github上的源代码:地址 ,精简后的源代码地址 ...
- git项目创建
1.在gitserver上创建git项目如图 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill ...
- [WebGL入门]二十一,从平行光源发出的光
注:文章译自http://wgld.org/,原作者杉本雅広(doxas),文章中假设有我的额外说明.我会加上[lufy:],另外,鄙人webgl研究还不够深入,一些专业词语.假设翻译有误,欢迎大家指 ...
- 02-JZ2440裸机学习之GPIO实验【转】
本文转载自:http://blog.csdn.net/fengyuwuzu0519/article/details/54910717 版权声明:本文为博主原创文章,转载请注明http://blog.c ...
- P3225 [HNOI2012]矿场搭建 tarjan割点
这个题需要发现一点规律,就是先按割点求块,然后求每个联通块中有几个割点,假如没有割点,则需要建两个出口,如果一个割点,则需要建一个出口,2个以上不用建. 题干: 题目描述 煤矿工地可以看成是由隧道连接 ...
- JAVA基础(多线程Thread和Runnable的使用区别(转载)
转自:http://jinguo.iteye.com/blog/286772 Runnable是Thread的接口,在大多数情况下“推荐用接口的方式”生成线程,因为接口可以实现多继承,况且Runnab ...
- vue实现全选,反选
1.example.vue <template> <table class="table-common"> <tr> <th class= ...