I have created a source file with multiple procedures. The source file declares global variables within the procedure. When my main program sources the source file and executes one of the procedures, the global variable in that sourced procedure does not appear to be global to the main program. Is this just a syntax issue, or am I unable to declare a global variable in a sourced file?
example) source.exp #source file
proc procCftStart { } {
global procCftStatus
global procCftSpawnId
global procCftPid
set procCftStatus 1
send_user "procCftStat = $procCftStatus\n"
...
}
example) main.exp #main program
source ./source.exp
...
procCftStart # Call procedure in source.exp
if { $procCftStatus != 1 } { # program dies here
send_user "ERROR: Shell Failure - $Cft\n"
exit
}
error)
procCftStatus = 1 #Sent by procedure called by main
can't read "procCftStatus": no such variable # Error sent by main when trying to read global variable.
example) source.exp #source file
proc procCftStart { } {
global procCftStatus
global procCftSpawnId
global procCftPid
set procCftStatus 1
send_user "procCftStat = $procCftStatus\n"
...
}
example) main.exp #main program
source ./source.exp
...
procCftStart # Call procedure in source.exp
if { $procCftStatus != 1 } { # program dies here
send_user "ERROR: Shell Failure - $Cft\n"
exit
}
error)
procCftStatus = 1 #Sent by procedure called by main
can't read "procCftStatus": no such variable # Error sent by main when trying to read global variable.