1 |
# SCCSid "$SunId$ LBL" |
2 |
# |
3 |
# General utility routines |
4 |
# |
5 |
|
6 |
proc beep {} { # ring the bell |
7 |
puts -nonewline stderr "\a" |
8 |
} |
9 |
|
10 |
proc view_txt fn { # view a text file |
11 |
global env |
12 |
if [info exists env(EDITOR)] { |
13 |
eval exec xterm -e $env(EDITOR) $fn |
14 |
} else { |
15 |
foreach f $fn { |
16 |
exec xedit $f |
17 |
} |
18 |
} |
19 |
} |
20 |
|
21 |
proc cardval {var cvl} { # set variable to one of a set of values |
22 |
upvar $var v |
23 |
set tv [string toupper $v] |
24 |
foreach cv $cvl { |
25 |
if {[string first $tv [string toupper $cv]] == 0} { |
26 |
set v $cv |
27 |
return $cv |
28 |
} |
29 |
} |
30 |
return {} ; # this would seem to be an error |
31 |
} |
32 |
|
33 |
proc writevars {f vl} { # write variables to a file |
34 |
foreach v $vl { |
35 |
upvar $v myv |
36 |
if [catch {set il [array names myv]}] { |
37 |
puts $f "set $v [list $myv]" |
38 |
} else { |
39 |
foreach i $il { |
40 |
puts $f "set ${v}($i) [list $myv($i)]" |
41 |
} |
42 |
} |
43 |
} |
44 |
} |