try
    screens = Screen('Screens');
    whichscreen = max(screens);
    [w, rect] =Screen('Openwindow', whichscreen, 0);
    frame = CenterRect([0, 0, rect(3)/2, rect(4)/2], rect);
    x = frame(1);
    y = rect(4)/2;
    Screen('TextSize', w, 24);
    for i = 0:600
        Screen('FillRect', w, 255, frame);
        Screen('DrawText', w, 'hello world!', x, y);
        Screen('Flip', w);
        x = x + (round(rand)*4)-1;
        y = y + (round(rand)*2)-1;
    end
    Screen('CloseAll'); % close all
catch
    Screen('Close',w)
    rethrow(lasterror)
end