File: structlib.tcl

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (63 lines) | stat: -rw-r--r-- 1,338 bytes parent folder | download | duplicates (6)
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
############################################################################
# routines to create structures in tcl, and get & set fields.
############################################################################

global St_

# This line taken out since auto-pathing should now be in place
# (Mark 9/21/94)
# source unique.tcl

proc St_create {keylist args} {
    global St_

    if {[llength $keylist] == 0} {
        return
    } else {
	set token [unique index]
	set St_($token) [concat [list $keylist] $args]

	return $token
    }
}

proc St_set {token key val} {
    global St_
    
    if {[catch {set St_($token)}] == 0} {
        if {[llength $St_($token)] >= 2} {
    	    set index [lsearch [lindex $St_($token) 0] $key]
	    if {$index >= 0} {
	        if {[llength $St_($token)] >= $index} {
	            incr index
                    set St_($token) [lreplace $St_($token) $index $index $val]
		    return $index 
		}
	    }
	}
    }
    return
}

proc St_get {token key} {
    global St_

    if {[catch {set St_($token)}] == 0} {
        if {[llength $St_($token)] >= 2} {
            set index [lsearch [lindex $St_($token) 0] $key]
	    if {$index >= 0} {
	        if {[llength $St_($token)] >= $index} {
		    incr index
		    return [lindex $St_($token) $index]
	        }
	    }
        }
    }
    return
}