-
Notifications
You must be signed in to change notification settings - Fork 2
/
openconf2.tcl
43 lines (37 loc) · 1.75 KB
/
openconf2.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
#!/usr/local/bin/env tclsh8.6
# OpenConf 2
proc blockwcb {blockname cb} {
proc $blockname {args} "$cb \$args"
}
proc blocktnd {blockname} {
set programme [list \
[list set blockname $blockname] \
[list tnda incr [format "openconf/%s/blocks" [ndcenc $blockname]] ] \
]
set blockpro {
puts stdout $args
tnda set [format "openconf/%s/n%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] [lindex $args end]
if {[llength [lrange $args 0 end-1]] > 0} {tnda set [format "openconf/%s/hdr%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] [lrange $args 0 end-1]}
}
lappend programme $blockpro
proc $blockname {args} [join $programme "\n"]
}
proc blocktndretfunc {blockname} {
set programme [list \
[list set blockname $blockname] \
[list tnda incr [format "openconf/%s/blocks" [ndcenc $blockname]] ] \
]
set blockpro {
puts stdout $args
tnda set [format "openconf/%s/n%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] [lindex $args end]
if {[llength [lrange $args 0 end-1]] > 0} {tnda set [format "openconf/%s/hdr%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] [lrange $args 0 end-1]}
}
lappend programme $blockpro
return [join $programme "\n"]
} ;#for making aliases of block procs
proc postblock {blockname headlines block} {
set blockname $blockname
tnda incr [format "openconf/%s/blocks" [ndcenc $blockname]]
tnda set [format "openconf/%s/n%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] $block
if {[llength $headlines] > 0} {tnda set [format "openconf/%s/hdr%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] $headlines}
}