Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Simple Problem - Command Prompt
Date: Wed, 4 Nov 2009 09:18:19 -0500
Organization: The MathWorks, Inc.
Lines: 41
Message-ID: <hcs2dj$9um$1@fred.mathworks.com>
References: <hcpvhk$ofg$1@fred.mathworks.com> <a9793a7a-116d-461a-9e62-60d65523a0a2@q40g2000prh.googlegroups.com> <hcrqhm$hj2$1@fred.mathworks.com> <398467f9-9532-4eee-9959-a00cd35e2836@r5g2000yqb.googlegroups.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1257344243 10198 172.31.44.65 (4 Nov 2009 14:17:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 14:17:23 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:582377



"ImageAnalyst" <imageanalyst@mailinator.com> wrote in message 
news:398467f9-9532-4eee-9959-a00cd35e2836@r5g2000yqb.googlegroups.com...
> On Nov 4, 7:03 am, "Ahmad " <climbe...@gmail.com> wrote:
> > I mean th command prompt which opens in which the code is executed when 
> > the exe is created from the m-file. I mean the command prompt
> environment in which the exe opens. Once it computes the results it closes 
> immediately! How should I make it remain open?
>
> ------------------------------------------------------------------------------------------------------------------------------------
> You need to open a command window and run your exe from there.  If you
> just double click the icon, it will open the command window briefly,
> crash and dump the error message to it, and then (unfortunately) shut
> down that window.  This is what you're experiencing.

I don't think there's any crash involved.

When you run a function in MATLAB, once the function has finished executing, 
you return to the command prompt.
When you run a function in a compiled application, once the function has 
finished executing, the compiled application exits.  As part of the process 
of exiting, the application must close down any windows it created.

> If you open a separate command window manually (say with Start/Run/cmd
> in Windows XP), change directory to the folder, and run the program,
> the window won't shut down and any error messages will remain in view.
>
> Or alternatively run it from the command window panel in MATLAB with
> the ! operator, like this:
> !myapp
> Then the error messages will remain in the MATLAB command window.

Those are two options; alternately, use UIWAIT on the handle of a MSGBOX so 
that the function doesn't finish executing until the dialog is closed.

-- 
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ