TABLE OF CONTENTS
::pwtk::ifnotexist
SYNOPSIS
proc ::pwtk::ifnotexist {varName script args} {
USAGE
ifnotexist varName script ?else script2?
PURPOSE
Execute the $script only if the variable $varName does not exist.
SOURCE
upvar $varName var set narg [llength $args] if { $narg > 0 } { if { [lindex $args 0] != "else" } { ::error "invalid command name [lindex $args 0]" } elseif { $narg != 2 } { ::error "wrong # args: should be \"if exists varName script ?else script?\"" } } set result {} set code 0 if { ! [info exists var] } { set code [catch {uplevel 1 $script} result] } elseif { $narg == 2} { set code [catch {uplevel 1 [lindex $args end]} result] } return -code $code $result }