What does this error mean?

Error in GetMouse (line 239)
screenRect=Screen(‘GlobalRect’,windowPtrOrScreenNumber);

Error in mouseresponse (line 110)
[x2,y2,buttons2]=GetMouse(window);

I have three different while loops, each one is a level. when mouse response for level 1 is met, it goes to 2 and then to level 3 if the mouse response for level 2 is met. The problem is i’m unable to make it step out of level 2 even after the mouse response. I’m guessing there is something wrong with my mouse initiation in level 2.

You didn’t include the actual error message, only the location where the error occurred. Please send the error (above these) as well

Error in function GlobalRect: Usage error
Argument was recognized as neither a window index nor a screen pointer
Error using Screen
Usage:

rect=Screen(‘GlobalRect’, windowPointerOrScreenNumber);

Error in GetMouse (line 239)
screenRect=Screen(‘GlobalRect’,windowPtrOrScreenNumber);

The error is what it says, when you call
[x2,y2,buttons2]=GetMouse(window); the variable “window” does not contain a window pointer. Window pointer is the thing you use to Screen(‘flip’) and such as well.
I strongly recommend you first do some of Peter Scarfe’s tutorials and really understand them, or if you have access, have a chat with someone who knows PTB around you. That’ll help you resolve a lot of these things yourself.

1 Like

Hi, thanks for taking your time to respond. i have gone through the online tutorials but its still not clear to me. As far as i understand window pointer refers to the window just opened right. I’m not sure why it does not recognizes the pointer. this is how i have initiated it. It would be extremely helpful if you could point out where i could be wrong.

    sca;
    close all;
    clear all;
    Screen('Preference', 'SkipSyncTests',2); 

PsychDefaultSetup(2);
screen=max(Screen('Screens'));
%opening window
[window, windowRect]=PsychImaging('Openwindow', screen, [0.2 0.2 0.2], [0 0 900 900]);

If there is an error in your code somewhere after you have opened your screen, the screen may be forced to close, and a subsequent call with the window pointer will cause an error as the window pointer is no longer valid…

1 Like