-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.tcl
71 lines (58 loc) · 1.48 KB
/
util.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
set util_unique_id 0
proc util.unique_id token {
global util_unique_id
incr util_unique_id
return "$token$util_unique_id"
}
proc util.populate_array { array text } {
upvar $array a
set keyword ""
foreach item $text {
if { $keyword != "" } {
set a($keyword) $item
set keyword ""
} {
set keyword $item
regsub ":" $keyword "" keyword
}
}
}
proc util._populate_array { array text } {
upvar $array a
set keyword ""
set space [string first " " $text]
set item [string range $text 0 [expr $space - 1]]
set text [string range $text [expr $space + 1] end]
while { $item != "" } {
if { $keyword != "" } {
set a($keyword) $item
set keyword ""
} {
set keyword $item
regsub ":" $keyword "" keyword
}
set space [string first " " $text]
set item [string range $text 0 [expr $space - 1]]
set text [string range $text [expr $space + 1] end]
}
set a($keyword) $text
}
proc util.version {} {
global tkmooVersion
return $tkmooVersion
}
proc util.buildtime {} {
global tkmooBuildTime
return $tkmooBuildTime
}
proc util.slice { list { n 0 } } {
set tmp {}
foreach item $list { lappend tmp [lindex $item $n] }
return $tmp
}
proc util.assoc { list key { n 0 } } {
foreach item $list {
if { [lindex $item $n] == $key } { return $item }
}
return {}
}