Hi folks,
I'm having some problems using ASK in/with RUSHed code.
If I put more than one ASK statement in my RUSHed code, I get the
following error:
"??? Error during RUSH: Can't call WaitNextEvent while priority>0."
Here's the RUSHed code:
trial = {
'Ask(window2, beginstring, 255, 0, ''KbWait'');'
'secs1 = KbWait;'
'Screen(window1, ''WaitBlanking'', x1);'
'Screen(window1, ''DrawText'', ''+'', 576, 432, 255);'
'Screen(''CopyWindow'', window1, window2);'
'secs2 = GetSecs;'
'Screen(window2, ''WaitBlanking'', x2);'
'Screen(window1, ''FillRect'', 0);'
'Screen(''CopyWindow'', window1, window2);'
'secs3 = GetSecs;'
'Screen(window1, ''DrawText'', target, 560, 416, 255);'
'Screen(window1, ''DrawText'', distractor, 592, 416, 255);'
'Screen(window1, ''DrawText'', distractor, 560, 448, 255);'
'Screen(window1, ''DrawText'', distractor, 592, 448, 255);'
'Screen(''CopyWindow'', window1, window2);'
'secs4 = KbWait;'
'Screen(window1, ''FillRect'', 0);'
'Screen(''CopyWindow'', window1, window2);'
'char = Ask(window2, ''Accept Trial?'', 255, 0, ''GetChar'');'
};
But, this error doesn't occur if I remove the second ASK statement in
the loop with RUSH priority set to 1.
If I set the RUSH priority to 0 the code does not generate an error,
but, the second ASK statement is executed without pausing for input.
Occasionally, I see the "Accept Trial?" text flash extremely briefly,
but there is no pause for input at all.
If I change the second ASK statement to this:
'Ask(window2, ''Accept Trial?'', 255, 0, ''GetChar'');'
'char = GetChar;'
there is no difference.
In both cases, the program does create the "char" variable and appears
to leave it blank, regardless of what key is pressed, but the ASK
statement doesn't pause for input. Yet, if I do ISCHAR on the "char"
variable, it returns "ans = 1", indicating that "char" does contain a
character.
Now, I have found a possible work around but it's awkward. The call
to RUSH for this code is in a FOR loop to count down the number of
trials for the experiment. If I repeat the ASK statement using either
of the forms above in the FOR loop after the call to RUSH, as well as
in the RUSHed code, then the ASK statement does pause for input. But,
two keypresses are required with the first not registering at all, and
only the second being recorded into the "char" variable.
If anyone has any insight into this, I'd appreciate any help you could
provide. Ideally I'd like to be able to make this work with as little
code as possible (that is, using only one ASK statement in the FOR
loop and not in the RUSHed code so I can run RUSH at priority 1), and
to not have to do 2 keypresses to make it work.
Thanks in advance,
Paul Thiem
UC Santa Cruz
I'm having some problems using ASK in/with RUSHed code.
If I put more than one ASK statement in my RUSHed code, I get the
following error:
"??? Error during RUSH: Can't call WaitNextEvent while priority>0."
Here's the RUSHed code:
trial = {
'Ask(window2, beginstring, 255, 0, ''KbWait'');'
'secs1 = KbWait;'
'Screen(window1, ''WaitBlanking'', x1);'
'Screen(window1, ''DrawText'', ''+'', 576, 432, 255);'
'Screen(''CopyWindow'', window1, window2);'
'secs2 = GetSecs;'
'Screen(window2, ''WaitBlanking'', x2);'
'Screen(window1, ''FillRect'', 0);'
'Screen(''CopyWindow'', window1, window2);'
'secs3 = GetSecs;'
'Screen(window1, ''DrawText'', target, 560, 416, 255);'
'Screen(window1, ''DrawText'', distractor, 592, 416, 255);'
'Screen(window1, ''DrawText'', distractor, 560, 448, 255);'
'Screen(window1, ''DrawText'', distractor, 592, 448, 255);'
'Screen(''CopyWindow'', window1, window2);'
'secs4 = KbWait;'
'Screen(window1, ''FillRect'', 0);'
'Screen(''CopyWindow'', window1, window2);'
'char = Ask(window2, ''Accept Trial?'', 255, 0, ''GetChar'');'
};
But, this error doesn't occur if I remove the second ASK statement in
the loop with RUSH priority set to 1.
If I set the RUSH priority to 0 the code does not generate an error,
but, the second ASK statement is executed without pausing for input.
Occasionally, I see the "Accept Trial?" text flash extremely briefly,
but there is no pause for input at all.
If I change the second ASK statement to this:
'Ask(window2, ''Accept Trial?'', 255, 0, ''GetChar'');'
'char = GetChar;'
there is no difference.
In both cases, the program does create the "char" variable and appears
to leave it blank, regardless of what key is pressed, but the ASK
statement doesn't pause for input. Yet, if I do ISCHAR on the "char"
variable, it returns "ans = 1", indicating that "char" does contain a
character.
Now, I have found a possible work around but it's awkward. The call
to RUSH for this code is in a FOR loop to count down the number of
trials for the experiment. If I repeat the ASK statement using either
of the forms above in the FOR loop after the call to RUSH, as well as
in the RUSHed code, then the ASK statement does pause for input. But,
two keypresses are required with the first not registering at all, and
only the second being recorded into the "char" variable.
If anyone has any insight into this, I'd appreciate any help you could
provide. Ideally I'd like to be able to make this work with as little
code as possible (that is, using only one ASK statement in the FOR
loop and not in the RUSHed code so I can run RUSH at priority 1), and
to not have to do 2 keypresses to make it work.
Thanks in advance,
Paul Thiem
UC Santa Cruz