openconf2.tcl (1790B)
1 #!/usr/local/bin/env tclsh8.6 2 3 # OpenConf 2 4 5 proc blockwcb {blockname cb} { 6 proc $blockname {args} "$cb \$args" 7 } 8 9 proc blocktnd {blockname} { 10 set programme [list \ 11 [list set blockname $blockname] \ 12 [list tnda incr [format "openconf/%s/blocks" [ndcenc $blockname]] ] \ 13 ] 14 set blockpro { 15 puts stdout $args 16 tnda set [format "openconf/%s/n%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] [lindex $args end] 17 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]} 18 } 19 lappend programme $blockpro 20 proc $blockname {args} [join $programme "\n"] 21 } 22 23 proc blocktndretfunc {blockname} { 24 set programme [list \ 25 [list set blockname $blockname] \ 26 [list tnda incr [format "openconf/%s/blocks" [ndcenc $blockname]] ] \ 27 ] 28 set blockpro { 29 puts stdout $args 30 tnda set [format "openconf/%s/n%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] [lindex $args end] 31 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]} 32 } 33 lappend programme $blockpro 34 return [join $programme "\n"] 35 } ;#for making aliases of block procs 36 37 proc postblock {blockname headlines block} { 38 set blockname $blockname 39 tnda incr [format "openconf/%s/blocks" [ndcenc $blockname]] 40 tnda set [format "openconf/%s/n%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] $block 41 if {[llength $headlines] > 0} {tnda set [format "openconf/%s/hdr%s" [ndcenc $blockname] [tnda get [format "openconf/%s/blocks" [ndcenc $blockname] ] ]] $headlines} 42 } 43