ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/util.tcl
Revision: 2.4
Committed: Sat Feb 22 02:07:30 2003 UTC (21 years, 7 months ago) by greg
Content type: application/x-tcl
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R5, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1, rad5R3, HEAD
Changes since 2.3: +1 -1 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# User Rev Content
1 greg 2.4 # RCSid: $Id$
2 greg 2.1 #
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 greg 2.3 if {[lsearch -exact {vi vedit view ex edit ed red} \
14     [file tail [lindex $env(EDITOR) 0]]] >= 0} {
15     eval exec xterm +sb -e $env(EDITOR) $fn
16     } else {
17     eval exec $env(EDITOR) $fn
18     }
19 greg 2.1 } else {
20     foreach f $fn {
21     exec xedit $f
22     }
23     }
24     }
25    
26     proc cardval {var cvl} { # set variable to one of a set of values
27     upvar $var v
28     set tv [string toupper $v]
29     foreach cv $cvl {
30     if {[string first $tv [string toupper $cv]] == 0} {
31     set v $cv
32     return $cv
33     }
34     }
35     return {} ; # this would seem to be an error
36     }
37 greg 2.2
38     proc writevars {f vl} { # write variables to a file
39     foreach v $vl {
40     upvar $v myv
41     if [catch {set il [array names myv]}] {
42     puts $f "set $v [list $myv]"
43     } else {
44     foreach i $il {
45     puts $f "set ${v}($i) [list $myv($i)]"
46     }
47     }
48     }
49     }