I would modify your script to put it in a proc.
proc database_call { args } {
set arg_values $args
set SERVER [lindex $arg_values 0]
set DATA_BASE_ENTRY [lindex $arg_values 1]
set USER [lindex $arg_values 2]
...
# don't echo the value from within your proc. it isn't necessary.
#echo $VALUE
...
odbc SQLFreeHandle SQL_HANDLE_ENV $henv
#echo hello
return $VALUE
}
echo [database_call $argv]
The last “echo” line is only for when you are calling this script from the shell. If you only call it from TCL, then this is unnecessary.
You can either put this in your TCL auto_path directory (and run mktclindex in that directory) or you can put “source /path/to/script/database_call.tcl” in the TPS proc before you call it.
To call the proc, you should be able to say:
set value2 [database_call “SERVER” “INI ENTRY” “user” “pword” “Accident” “description” “Illness”” “code”]
You’re also better off listing the argument names in your proc definition. The use of the word “args” as a parameter is special and is not how you should normally write procs.