| Glenn Jackman 2007-06-25, 10:10 pm |
| At 2007-06-25 08:52AM, "tcltkdev@aol.com" wrote:
> package require tequila
>
> tequila::pool tqca [tequila::rpc tinyxp 18396]
> tqca attach item
>
> set item(100) 1
>
> set a item(100)
Here, variable "a" will contain the literal value "item(100)". If you
wanted instead for "a" to have the value "1", you need to derefenrece
item(100) with a dollar sign:
set a $item(100)
> if {myproc $a} { puts ok}
Two things. One, command substitution requires [brackets]:
if {[myproc $a]} {puts ok}
Second, the command must be defined before being invoked. Many people
use the following style of writing their scripts:
# start of script
proc main {argv} {
# all main logic here
# can call any proc
}
proc foo {} {}
proc bar {} {}
# ... other procs
# now, invoke the "main" proc and pass any parameters
main $argv
# end of script
> ########################################
##########
> proc myproc { resource } {
> if {![info exists $resource]} {
> set $resource 1
> return 1
> } elseif { $resource == 1 }
>
> }
> }
It looks like you want to pass to myproc a variable *name* instead of a
value. Try this:
proc myproc {resourceName} {
upvar $resourcename resource
if { ! [info exists resource]} {
set resource 1
} elseif {$resource == 1}
#do something
}
return $resource
}
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
|