
Prompt function is not allowed in ThreadSafe function

viralvector
Apparently, I cannot use the function of prompt in ThreadSafe...
e.g.
ThreadSafe Function ThreadWorker(wIn, wln_control, waveIndex,xr,xl)
variable xr,xl
....
Prompt xl, "Enter left bracket:"
Prompt xr, "Enter right bracket:"
DoPrompt "Enter left and right", xl, xr
wave w1 = wln_control
duplicate/R=(xl, xr)/FREE w1, rw, bdw
duplicate/R=(xl, xr)/FREE wIn, tdw
rw = (bdw - tdw)^2 / numpnts(rw)
Variable MeanSquare = sum(rw)
....
Any workaround ideas?
Thanks in advance.
It doesn't really make sense to ask for user input from a thread- that's a technique to gain high performance. Waiting for a user to enter data is not high performance.
I presume that what you want is to thread a computation for speed, but that computation needs user input. Your prompts need to be in the driver function so that the inputs can be collected first, then passed into the thread worker functions, possibly via input parameters.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 5, 2014 at 04:32 pm - Permalink
Your presumption is right! but I don't know how to integrate the function into the driver function.
This is what I have tried, and I received:
"Expected operand"
Igor found an operator where it expected an operand.
This can also happen if you forget to use a comma after a numeric operand
Here is the code:
June 6, 2014 at 11:46 am - Permalink
But keep your function, and move the Prompt/DoPrompt out if it into another function. Put all the UI code in that second function (that is, Prompt and DoPrompt) and have it call your engine function. Something like this:
I like to start my menu-servicing functions with "m" to remind me what it's for. And it allows me to use the same function name as the engine that it calls.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 6, 2014 at 02:32 pm - Permalink
I like your way of managing macro functions with "m", and the code works flawlessly.
Thank you very much and have a nice weekend! johnweeks
June 6, 2014 at 06:17 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 9, 2014 at 09:36 am - Permalink