i have a tcl script used for test automation (with CarMaker ScriptControl interface)
In the script i am calling a proc where some code is executed that may take a few milliseconds before it returns. However, if at a certain point in this proc it gets called again, the second call will fail and cause an error.
I have no control about when the proc will be called, because the calls come from another application. What i am searching for is a way to prevent a parallel call to the function happening while a certain part of my code is being executed.
Something like this:
proc MyProc {args} {
#Execute Code
set val 0
#---this part should not be interrupt
#Execute non interrupt Code
RegisterQuantities ($names)
Foreach name {
ReadQuantity $name
}
#------------------------------------
return val
}
The calls come from a realtime PC that
The simplest way of doing this is to create a global variable that says whether the code has reached the point where the procedure may be usefully called:
Then all you need to do is call
ReadyForCallat the point where the command becomes callable (which you can probably characterise fairly well).