📄 static.tcl
字号:
#
# DESCRIPTION
# This file contains a procedure written in Tcl that supports static
# variables.
#
#+ static - static variables support
#
# This procedure supports static variables for a procedure whole through
# Tcl code. This procedure is based on code from the authors of the
# tclX extension.
#
# REQUIREMENTS
# None.
#
# RETURNS
# Nothing.
#
# EXAMPLE
# static {foo 10} bar
#
# CAVEATES
# None.
#
proc static {args} {
global staticvars
set procName [lindex [info level -1] 0]
foreach varPair $args {
set varName [lindex $varPair 0]
if {[llength $varPair] != 1} {
set varValue [lrange $varPair 1 end]
} else {
set varValue {}
}
if {! [info exists staticvars($procName:$varName)]} {
set staticvars($procName:$varName) $varValue
}
uplevel 1 "upvar #0 staticvars($procName:$varName) $varName"
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -