lappend

http://blog.csdn.net/dulixin/article/details/2178837
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
VIVADO经常使用TCL脚本对FPGA进行调试,通过JTAG转AXI对内部模块进行控制,但是TCL语言书籍比较少,这边是一个英文的TCL语言学习书籍. 第 1 章. TCL基本知识................................................................................................................1 1.1 什么是TCL..............................................................................................................................1 1.2 TCL自学工具...........................................................................................................................1 1.3 TCL软件包..............................................................................................................................2 1.4 TCL命令格式...........................................................................................................................2 1.5 TCL脚本文件和SOURCE 命令..................................................................................................3 1.6 可执行脚本文件(EXECUTABLE FILE)...........................................................................................3 1.7 获得帮助.................................................................................................................................4 1.7.1 Windows系统.............................................................................................................4 1.7.2 Unix系统......................................................................................................................4 第 2 章. 输出、赋值与替换........................................................................................................5 2.1 PUTS.........................................................................................................................................5 2.2 SET & UNSET..............................................................................................................................5 2.3 替换........................................................................................................................................6 2.3.1 $...................................................................................................................................6 2.3.2 []..................................................................................................................................6 2.3.3 " " 和{}..........................................................................................................................6 2.3.4 \...................................................................................................................................7 第 3 章. 数学表达式与EXPR命令..............................................................................................8 3.1 数学和逻辑运算符..................................................................................................................8 3.2 数学函数.................................................................................................................................8 3.3 数学运算举例.........................................................................................................................9 3.4 INCR命令................................................................................................................................9 第 4 章. 字符串........................................................................................................................10 4.1 基本命令集...........................................................................................................................10 4.2 APPEND命令..........................................................................................................................10 4.3 FORMAT命令..........................................................................................................................10 4.3.1 format命令说明......................................................................................................10 4.3.2 format举例..............................................................................................................11 4.4 SCAN命令.............................................................................................................................12 4.5 BINARY命令...........................................................................................................................13 4.6 SUBST命令..............................................................................................................................14 4.7 STRING 命令...........................................................................................................................15 4.7.1 string 命令列表.........................................................................................................15 4.7.2 字符串比较................................................................................................................16 4.7.3 string match字符串匹配.........................................................................................16 4.7.4 字符串替换................................................................................................................18 4.7.5 字符类别(class)测试.................................................................................................18 4.7.6 字符串映射................................................................................................................19 第 5 章. TCL列表操作..............................................................................................................20 5.1 列表命令集...........................................................................................................................20 5.2 LIST命令.................................................................................................................................20 5.3 CONCAT命令.........................................................................................................................21 5.4 LAPPEND命令........................................................................................................................21 5.5 LLENGTH 命令.........................................................................................................................22 5.6 LINDEX命令............................................................................................................................22 5.7 LRANGE命令..........................................................................................................................22 5.8 LINSERT 和LREPLACE命令........................................................................................................22 5.9 LSEARCH命令.........................................................................................................................23 5.10 LSORT命令.............................................................................................................................24 5.11 JOIN与SPLIT命令...................................................................................................................24 5.12 FOREACH控制结构................................................................................................................27 第 6 章. 数组............................................................................................................................28 6.1 数组的定义与格式................................................................................................................28 6.2 数组变量...............................................................................................................................29 6.3 多维数组...............................................................................................................................29 6.4 数组操作命令.......................................................................................................................30 6.4.1 array get命令.........................................................................................................30 6.4.2 array names命令....................................................................................................30 6.4.3 遍历数组...................................................................................................................31 6.4.4 用数组定义结构........................................................................................................31 第 7 章. 控制结构命令.............................................................................................................32 7.1 IF/ELSE命令............................................................................................................................32 7.2 FOR命令................................................................................................................................33 7.3 WHILE命令.............................................................................................................................33 7.4 BREAK 与 CONTINUE命令........................................................................................................34 7.5 SWITCH命令...........................................................................................................................34 7.6 CATCH 命令...........................................................................................................................35 7.7 ERROR命令............................................................................................................................36 7.8 RETURN 命令...........................................................................................................................37 7.9 EXIT命令................................................................................................................................37 第 8 章. 过程与作用域.............................................................................................................38 8.1 PROC—过程定义命令...........................................................................................................38 8.2 作用域...................................................................................................................................40 8.2.1 过程的作用域............................................................................................................40 8.2.2 变量的作用域............................................................................................................40 8.3 UPVAR命令............................................................................................................................42 8.4 RENAME命令.........................................................................................................................44 8.5 特殊变量...............................................................................................................................45 8.5.1 命令行参数................................................................................................................45 8.5.2 env--环境变量数组...................................................................................................45 8.6 EVAL命令..............................................................................................................................46 8.7 UPLEVEL命令..........................................................................................................................48 第 9 章. 正则表达式(REGULAR EXPRESSIONS)...................................................................49 9.1 REGEXP命令..........................................................................................................................49 9.2 REGSUB命令...........................................................................................................................51 9.3 正则表达式的语法................................................................................................................52 9.3.1 分支(branch)和原子(atom)....................................................................................52 9.3.2 基本语法...................................................................................................................52 9.3.2.1 匹配字符........................................................................................................................................52 9.3.2.2 限定匹配........................................................................................................................................53 9.3.2.3 方括号表达式与字符集.................................................................................................................53 9.3.2.4 匹配分支........................................................................................................................................54 9.3.2.5 量词(Qulifier)...........................................................................................................................54 9.3.2.6 子模式与匹配报告捕获.................................................................................................................55 9.3.2.7 反斜杠引用....................................................................................................................................56 9.3.2.8 匹配优先级....................................................................................................................................56 9.3.3 高级正则表达式(AREs).........................................................................................57 9.3.3.1 反斜杠换码(escape)序列............................................................................................................57 9.3.3.2 归整元素(collating element).....................................................................................................57 9.3.3.3 等价类(equivalence class)........................................................................................................58 9.3.3.4 字符类(character class).............................................................................................................58 9.3.3.5 非贪婪量词....................................................................................................................................59 9.3.3.6 约束量词........................................................................................................................................59 9.3.3.7 回退引用........................................................................................................................................59 9.3.3.8 前瞻(lookahead).........................................................................................................................60 9.3.3.9 换行符敏感的匹配.........................................................................................................................60 9.3.3.10 嵌入式选项...............................................................................................................................60 9.3.3.11 扩展语法...................................................................................................................................60 9.3.4 语法小结...................................................................................................................60 9.3.5 其它支持正则表达式的命令......................................................................................60 第 10 章. 名字空间.................................................................................................................62 10.1 创建名字空间...................................................................................................................62 10.2 用::限定符来使用变量和过程...........................................................................................62 10.3 名字空间的变量...............................................................................................................63 10.4 过程的进口与出口............................................................................................................64 10.5 内省(INTROSPECTION).........................................................................................................65 10.6 名字空间命令集...............................................................................................................65 第 11 章. 跟踪与调试.............................................................................................................67 11.1 CLOCK命令...........................................................................................................................67 11.1.1 clock clicks命令......................................................................................................67 11.1.2 clock seconds命令................................................................................................67 11.1.3 clock format命令...................................................................................................68 11.1.4 clock scan命令.......................................................................................................70 11.2 INFO 命令...............................................................................................................................71 11.2.1 info level..................................................................................................................72 11.2.2 info exists.................................................................................................................72 11.3 TRACE命令............................................................................................................................73 11.3.1 trace variable.........................................................................................................73 11.3.2 trace vdelete..........................................................................................................75 11.3.3 trace vinfo...............................................................................................................75 第 12 章. 脚本库与软件包......................................................................................................76 12.1 声明和使用软件包............................................................................................................76 12.1.1 软件包定位................................................................................................................76 12.1.2 声明软件包命令........................................................................................................76 12.1.3 加载软件包命令........................................................................................................76 12.1.4 自动加载与软件包索引.............................................................................................77 12.1.5 用链接库提供软件包.................................................................................................79 12.2 PACKAGE命令集...................................................................................................................80 12.3 小结..................................................................................................................................80 第 13 章. 文件操作与程序调用...............................................................................................81 13.1 文件操作...........................................................................................................................81 13.1.1 文件I/O....................................................................................................................81 13.1.2 文件系统信息命令.....................................................................................................82 13.1.2.1 glob命令.................................................................................................................................83 13.1.2.2 file命令集.................................................................................................................................83 13.2 程序调用...........................................................................................................................85 13.2.1 用open命令打开一个进程管道..............................................................................85 13.2.2 用exec命令调用程序..............................................................................................87 13.2.3 pid命令....................................................................................................................88 第 14 章. 套接字与事件驱动编程简介....................................................................................89 14.1 套接字编程.......................................................................................................................89 14.1.1 socket命令..............................................................................................................89 14.1.1.1 Client端socket命令..............................................................................................................89 14.1.1.2 Server端socket命令选项......................................................................................................90 14.1.2 用fconfigure配置套接字........................................................................................90 14.1.3 C/S编程举例............................................................................................................90 14.2 事件驱动编程...................................................................................................................93 14.2.1 after命令.................................................................................................................93 14.2.2 fileevent命令..........................................................................................................96 14.2.3 vwait命令................................................................................................................96 14.2.4 fconfigure命令.......................................................................................................97 14.2.4.1 fconfigure语法.......................................................................................................................97 14.2.4.2 非阻塞I/O................................................................................................................................98 14.2.4.3 缓冲..........................................................................................................................................98
TCL(Tool Command Language) 本书籍由浅入深系统地介绍了Tcl语言,是学习Tcl语言的良师益友 Tcl编程初步 总目录 总目录 I 例索引. IV 表索引.VI 图索引VII 第 1 章. TCL基本知识 1 1.1 什么是 TCL ..1 1.2 TCL自学工具..1 1.3 TCL软件包 ..2 1.4 TCL命令格式..2 1.5 TCL脚本文件和 SOURCE 命令..3 1.6 可执行脚本文件(EXECUTABLE FILE) .3 1.7 获得帮助..4 1.7.1 Windows系统.4 1.7.2 Unix系统4 第 2 章. 输出、赋值与替换.. 5 2.1 PUTS .5 2.2 SET & UNSET ..5 2.3 替换6 2.3.1 $.6 2.3.2 [] 6 2.3.3 " " 和{} .6 2.3.4 \.7 第 3 章. 数学表达式与 EXPR命令. 8 3.1 数学和逻辑运算符..8 3.2 数学函数..8 3.3 数学运算举例9 3.4 INCR命令 .9 第 4 章. 字符串.. 10 4.1 基本命令集..10 4.2 APPEND命令.10 4.3 FORMAT命令.10 4.3.1 format 命令说明 10 4.3.2 format 举例.. 11 4.4 SCAN命令.12 4.5 BINARY命令..13 4.6 SUBST命令..14 4.7 STRING 命令 ..15 4.7.1 string 命令列表 15 4.7.2 字符串比较 16 4.7.3 string match字符串匹配.. 16 4.7.4 字符串替换 18 4.7.5 字符类别(class)测试. 18 4.7.6 字符串映射 19 第 5 章. TCL列表操作.. 20 5.1 列表命令集..20 5.2 LIST命令..20 5.3 CONCAT命令21 5.4 LAPPEND命令 ..21 5.5 LLENGTH 命令22 5.6 LINDEX命令22 5.7 LRANGE命令.22 5.8 LINSERT 和 LREPLACE命令..22 5.9 LSEARCH命令23 5.10 LSORT命令.24 5.11 JOIN与 SPLIT命令24 5.12 FOREACH控制结构27 第 6 章. 数组 28 6.1 数组的定义与格式28 6.2 数组变量29 6.3 多维数组29 6.4 数组操作命令.30 6.4.1 array get 命令 30 6.4.2 array names命令. 30 6.4.3 遍历数组 31 6.4.4 用数组定义结构.. 31 第 7 章. 控制结构命令. 32 7.1 IF/ELSE命令32 7.2 FOR命令.33 7.3 WHILE命令.33 7.4 BREAK 与 CONTINUE命令..34 7.5 SWITCH命令..34 7.6 CATCH 命令..35 7.7 ERROR命令36 7.8 RETURN 命令..37 7.9 EXIT命令.37 第 8 章. 过程与作用域. 38 8.1 PROC—过程定义命令..38 8.2 作用域.40 8.2.1 过程的作用域 40 8.2.2 变量的作用域 40 8.3 UPVAR命令42 8.4 RENAME命令 44 8.5 特殊变量45 8.5.1 命令行参数 45 8.5.2 env--环境变量数组 45 8.6 EVAL命令..46 8.7 UPLEVEL命令.48 第 9 章. 正则表达式(REGULAR EXPRESSIONS).. 49 9.1 REGEXP命令 .49 9.2 REGSUB命令..51 9.3 正则表达式的语法52 9.3.1 分支(branch)和原子(atom) 52 9.3.2 基本语法 52 9.3.2.1 匹配字符52 9.3.2.2 限定匹配53 9.3.2.3 方括号表达式与字符集.53 9.3.2.4 匹配分支54 9.3.2.5 量词(Qulifier)..54 9.3.2.6 子模式与匹配报告捕获.55 9.3.2.7 反斜杠引用..56 9.3.2.8 匹配优先级..56 9.3.3 高级正则表达式(AREs).. 57 9.3.3.1 反斜杠换码(escape)序列57 9.3.3.2 归整元素(collating element) ..57 9.3.3.3 等价类(equivalence class) ..58 9.3.3.4 字符类(character class).58 9.3.3.5 非贪婪量词..59 9.3.3.6 约束量词59 9.3.3.7 回退引用59 9.3.3.8 前瞻(lookahead)60 9.3.3.9 换行符敏感的匹配60 9.3.3.10 嵌入式选项60 9.3.3.11 扩展语法.60 9.3.4 语法小结 60 9.3.5 其它支持正则表达式的命令.. 60 第 10 章. 名字空间. 62 10.1 创建名字空间62 10.2 用::限定符来使用变量和过程.62 10.3 名字空间的变量 63 10.4 过程的进口与出口64 10.5 内省(INTROSPECTION) 65 10.6 名字空间命令集 65 第 11 章. 跟踪与调试. 67 11.1 CLOCK命令..67 11.1.1 clock clicks命令 67 11.1.2 clock seconds命令 67 11.1.3 clock format 命令 68 11.1.4 clock scan命令. 70 11.2 INFO 命令71 11.2.1 info level .. 72 11.2.2 info exists . 72 11.3 TRACE命令73 11.3.1 trace variable 73 11.3.2 trace vdelete. 75 11.3.3 trace vinfo 75 第 12 章. 脚本库与软件包 76 12.1 声明和使用软件包76 12.1.1 软件包定位 76 12.1.2 声明软件包命令.. 76 12.1.3 加载软件包命令.. 76 12.1.4 自动加载与软件包索引 77 12.1.5 用链接库提供软件包. 79 12.2 PACKAGE命令集80 12.3 小结80 第 13 章. 文件操作与程序调用.. 81 13.1 文件操作..81 13.1.1 文件 I/O. 81 13.1.2 文件系统信息命令.. 82 13.1.2.1 glob命令..83 13.1.2.2 file命令集..83 13.2 程序调用..85 13.2.1 用 open命令打开一个进程管道. 85 13.2.2 用 exec命令调用程序. 87 13.2.3 pid命令. 88 第 14 章. 套接字与事件驱动编程简介 89 14.1 套接字编程.89 14.1.1 socket 命令.. 89 14.1.1.1 Client端socket命令..89 14.1.1.2 Server端socket命令选项90 14.1.2 用 fconfigure配置套接字. 90 14.1.3 C/S编程举例 90 14.2 事件驱动编程93 14.2.1 after命令. 93 14.2.2 fileevent 命令. 96 14.2.3 vwait 命令 96 14.2.4 fconfigure命令 . 97 14.2.4.1 fconfigure语法.97 14.2.4.2 非阻塞I/O.98 14.2.4.3 缓冲 ..98 参考文献. 100 例索引 例 1-1 输出一段字符串的例子.. 2 例 1-2 source命令的简单例子 3 例 2-1 输出一个词的例子 5 例 2-2 参数定义、赋值与参数值引用 5 例 2-3 嵌套$用做替换操作. 6 例 2-4 命令替换[]的例子 6 例 2-5 {}替换的例子.. 6 例 2-6 \的例子.7 例 2-7 不规范的续行 7 例 3-1 数学运算举例. 9 例 4-1 append命令的简单例子. 10 例 4-2 位置说明符的例子. 11 例 4-3 format命令的简单例子. 11 例 4-4 scan命令的简单例子. 12 例 4-5 体验 binary format 和 binary scan的作用 13 例 4-6 binary命令的简单应用.. 14 例 4-7 subst命令的简单例子. 14 例 4-8 string compare 和 string equal进行字符串比较的例子. 16
1引言 2语法 2.1脚本、命令和单词符号 2.2置换(substitution) 2.2.1变量置换(variable subtitution) 2.2.2命令置换(command substitution) 2.2.3反斜杠置换(backslash substitution) 2.2.4双引号和花括号 2.3注释 3变量 3.1简单变量 3.2数组 3.3相关命令 3.3.1set 3.3.2unset 3.3.3append和incr 4表达式 4.1操作数 4.2运算符和优先级 4.3数学函数 5List 5.1list命令 5.2concat命令: 5.3lindex命令 5.4llength命令 5.5linsert命令 5.6lreplace命令: 5.7lrange 命令: 5.8lappend命令: 5.9lsearch 命令: 5.10lsort命令: 5.11split命令: 5.12join命令 6控制流 6.1if命令 6.2循环命令:while 、for、 foreach 6.2.1while命令 6.2.2for命令 6.2.3foreach命令 6.2.4break和continue命令 6.2.5switch 命令 6.1eval命令 6.2source命令 7过程(procedure) 7.1过程定义和返回值 7.2局部变量和全局变量 7.3缺省参数和可变个数参数 7.4引用:upvar 8字符串操作 8.1format命令 8.2scan命令 8.3regexp命令 8.4regsub命令 8.5string命令 8.5.1string compare ?-nocase? ?-length int? string1 string2 8.5.2string equal ?-nocase? ?-length int? string1 string2 8.5.3string first string1 string2 ?startindex? 8.5.4string index string charIndex 8.5.5string last string1 string2 ?startindex? 8.5.6string length string 8.5.7string match ?-nocase? pattern string 8.5.8string range string first last 8.5.9string repeat string count 8.5.10string replace string first last ?newstring? 8.5.11string tolower string ?first? ?last? 8.5.12string toupper string ?first? ?last? 8.5.13 string trim string ?chars? 8.5.14string trimleft string ?chars? 8.5.15string trimright string ?chars? 9文件访问 9.1文件名 9.2基本文件输入输出命令 9.3随机文件访问 9.4 当前工作目录 9.5文件操作和获取文件信息 10错误和异常 10.1错误 10.2从TCL脚本中产生错误 10.3使用catch捕获错误 10.4其他异常 11深入TCL 11.1查询数组中的元素 11.2 info命令 11.2.1变量信息 11.2.2过程信息 11.2.3命令信息 11.2.4 TCL的版本和库 11.2.5 命令的执行时间 11.2.6 跟踪变量 11.2.7 命令的重命名和删除 11.2.8 unknown命令 11.2.9自动加载 12历史记录 13TCL和C\C++ 13.1生成自己的TCLSH 13.2扩展自己的命令:方法(一) 13.2.1编写扩展命令对应的C/C++过程 13.2.2注册命令 13.2.3命令返回值和命令对应的过程的返回值 13.3扩展自己的命令:方法(二) 13.3.1Tcl_Obj结构 13.3.2编写扩展命令对应的C/C++过程 13.3.3注册命令 13.4利用clientData参数和deleteProc参数 13.5在C/C++应用程序中嵌入TCL 14总结

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值