1)写一个过程mysort,有两个参数,input是字符串,type是逆序方式(分为bylist方式和bystring方式,默认bylist方式)。 函数原型:proc mysort {input {type bylist}} 例如: mysort "hello" bystring 返回的结果是 olleh mysort "a b c d" bylist 返回的结果是 d c b a mysort "a b c d" 返回的结果是 d c b a mysort "abcd" *** 返回的结果是 "type不匹配!请指定bylist或bystring方式"
2)写一个文件处理函数,将in.txt里的内容读出来,并按照如下形式组合,然后讲组合内容存到out.txt中。 注: 1) in.txt --> out.txt 的过程中,true转为1,false转为0 2) 每行固定都有9个参数 3) 每行的参数都依次转为单列 4) 函数原型 convert {sourcefile targetfile} 例如: convert "c:/in.txt" "c:/out.txt" 5) 通过tclsh来调用(用source命令)
in.txt文件形式:
======================= 1 0 1 1 1 23 43 89 99 true false false true true 1 2 3 4 0 0 0 0 1 100 299 300 18 false 0 1 true 1 10 20 10 11 =======================
out.txt文件形式: ======================= 1 0 1 1 1 23 43 89 99 1 0 0 1 1 1 2 3 4 0 0 0 0 1 100 299 300 18 0 0 1 1 1 10 20 10 11 =======================
posted on 2008-01-20 15:59 LeoWang 阅读(41) 评论(0) 编辑 收藏
Powered by: 博客园 Copyright © LeoWang