How to break out of the program?

Hi all, how to break out of the program? Tried applekey-period but didn't work for os X
(worked for os 9 before). Thanks.
During the development phase of your OSX code, I want to echo what
others have advised before.

Put all you code in a try-catch statement with commands in the catch
section that release Screen when an error occurs. Something like
this:

try
% All your code here.
catch
% Basic list of commands that return you to your normal desktop.
ShowCursor;
Screen('CloseAll');
clear screen; % Not "clear all", so your variables will still
exist in workspace.
lasterr % No semicolon on "lasterr" so that it dumps to command window.
end

And then within your code in the try section, include a KbCheck
routine that intentionally crashes the program (e.g., simply try to
access a non-existing variable) within any long loops that you might
want to end prematurely. In one of my programs, at the top of the
trial loop, I have the following which allows me to press Q to quit
the program instead of starting the next trial:

% Wait for '0' number pad key to start trial.
response = [];
while (isempty(response))
WaitSecs(0.001);
[keyIsDown,secs,keyCode] = KbCheck;
if (keyIsDown)
if (length(find(keyCode)) > 1)
% Do nothing.
elseif (find(keyCode(KbName('0'))))
response = 1;
elseif (find(keyCode(KbName('q'))))
dummy_variable_to_quit_program; % Crashes here.
end
end
end

Daniel Shima
Vanderbilt Vision Research Center


On 9/16/05, rrenteri <rrenteri@...> wrote:
> --- In psychtoolbox@yahoogroups.com, "Fang" <fxj018100@u...> wrote:
> > Hi all, how to break out of the program? Tried applekey-period but
> didn't work for os X
> > (worked for os 9 before). Thanks.
>
> After pressing applekey-period, the screen is still hiding the Matlab
> command window. Try blindly typing "clear all" or
> "Screen('CloseAll')" (without the double-quotes), which should close
> the window and reveal the Finder.
>
> Best,
> Rene' Renteria
> Dept. Ophthalmology, UCSF
> (Also, I think typical etiquette here asks that you include your full
> name and an affiliation when posting.)
Thanks!

Best,
Fang
> X-Sieve: CMU Sieve 2.2
> Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
> DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lima; d=yahoogroups.com;
b=sI4BPCNEftqnDzwuEGnH+t2BOhLgBP7tUvgq7yJnsc8Ao2L1u0llJgk33fcyRhNlh1rg+ZLY/45F1c
Aht7BuL7w5lOpfFYJsPMWkYSj4e6vavRBcc8s6i3+E7SBhfRsK;
> X-Yahoo-Newman-Property: groups-email
> X-Sender: rrenteri@...
> X-Apparently-To: psychtoolbox@yahoogroups.com
> Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
> To: psychtoolbox@yahoogroups.com
> User-Agent: eGroups-EW/0.82
> X-Originating-IP: 216.155.201.68
> X-eGroups-Msg-Info: 1:12:0:0
> X-Yahoo-Post-IP: 128.218.19.116
> From: "rrenteri" <rrenteri@...>
> X-Yahoo-Profile: rrenteri
> X-eGroups-Approved-By: denispelli <denis.pelli@...> via email; 16 Sep 2005
18:02:14 -0000
> MIME-Version: 1.0
> Mailing-List: list psychtoolbox@yahoogroups.com; contact
psychtoolbox-owner@yahoogroups.com
> Delivered-To: mailing list psychtoolbox@yahoogroups.com
> List-Id: <psychtoolbox.yahoogroups.com>
> List-Unsubscribe: <mailto:psychtoolbox-unsubscribe@yahoogroups.com>
> Date: Fri, 16 Sep 2005 17:41:42 -0000
> Subject: [psychtoolbox] Re: How to break out of the program?
> Content-Transfer-Encoding: 7bit
> X-Virus-Scanned: amavisd-new at utdallas.edu
>

*****************************************
***********
Fang Jiang
School of Behavioral and Brain Sciences
GR 4.1
The University of Texas at Dallas
Richardson, TX 75083-0688
PHONE: 972-883-4983
FAX : 972-883-2491
***********
****************************************