NAME
VarExistsInCaller — Check if variable exists some levels up.
SYNOPSIS
VarExistsInCaller VarName ?LevelOffset?
DESCRIPTION
Return Value
1 It exists.
0 It does not exist.
Arguments
VarNameName of variable to check for.
LevelOffsetOptional. How many levels up to go. Default is 1 and will check the immediate caller.
More Info
This command uses uplevel and info exists to determine if the variable exists in the context of a caller.

For information regarding exceptions / errors, see here.
EXAMPLES

The following code demonstrates VarExistsInCaller in three ways:

  1. Variable does exist in immediate caller.
  2. Variable does not exist in immediate caller.
  3. It does not exist in preceding caller (though it does exist in immediate caller).

proc Proc0 {} {
Proc1
}
proc Proc1 {} {
set abc 123
Proc2
}
proc Proc2 {} {
puts [VarExistsInCaller abc]
puts [VarExistsInCaller def]
puts [VarExistsInCaller abc 2]
}
% Proc0
1
0
0
SEE ALSO
UpvarExistingOrDie, UpvarX
KEYWORDS
check, variable, verification