Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: How can delete a msgbox in a function

Subject: How can delete a msgbox in a function

From: Frank Pezzulo

Date: 16 May, 2008 14:11:01

Message: 1 of 4

Dear All,

I have a function that have at the end a msgbox. When i call
this function in one way i want to show this msgbox, but if
i call function in another way i don't want to show it. How
i can call the function without show msgbox?

Thanks

Francesco

Subject: Re: How can delete a msgbox in a function

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 16 May, 2008 17:28:18

Message: 2 of 4

In article <g0k4ll$mq7$1@fred.mathworks.com>,
Frank Pezzulo <john.doe.nospam@mathworks.com> wrote:

>I have a function that have at the end a msgbox. When i call
>this function in one way i want to show this msgbox, but if
>i call function in another way i don't want to show it. How
>i can call the function without show msgbox?

Sorry, I am not clear on what you mean by calling the function
"in another way".

If there is a way that you can determine by examining the input
arguments that the function was called one way or the other, then
you just wrap the msgbox() call within an if/end pair that does
the appropriate test.
--
'Roberson' is my family name; my given name is 'Walter'.

Subject: Re: How can delete a msgbox in a function

From: Frank Pezzulo

Date: 17 May, 2008 12:37:01

Message: 3 of 4

Hi Walter,

thanks for your reply. In total i call function 2 times. One
time i want show msgbox, the second one i call same function
but this time i don't want msgbox. Let me know if there is a
simple way to do it.

Thanks

Francesco








roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <g0kg7i$206$1@canopus.cc.umanitoba.ca>...
> In article <g0k4ll$mq7$1@fred.mathworks.com>,
> Frank Pezzulo <john.doe.nospam@mathworks.com> wrote:
>
> >I have a function that have at the end a msgbox. When i call
> >this function in one way i want to show this msgbox, but if
> >i call function in another way i don't want to show it. How
> >i can call the function without show msgbox?
>
> Sorry, I am not clear on what you mean by calling the function
> "in another way".
>
> If there is a way that you can determine by examining the
input
> arguments that the function was called one way or the
other, then
> you just wrap the msgbox() call within an if/end pair that
does
> the appropriate test.
> --
> 'Roberson' is my family name; my given name is 'Walter'.

Subject: Re: How can delete a msgbox in a function

From: us

Date: 17 May, 2008 14:43:01

Message: 4 of 4

"Frank Pezzulo":
<SNIP tired of his/her own messages...

> In total i call function 2 times. One
> time i want show msgbox, the second one i call same
function but this time i don't want msgbox....

one of the many solutions is outlined below
- copy/paste the snippet into a file <foo.m>
- at the command prompt, repeatedly type foo, eg,
     foo % <- shows msg
     foo % <- does not show msg
     foo % <- shows msg

function foo
if ~isempty(getappdata(0,'hasbox'))
     setappdata(0,'hasbox',[]);
else
     msgbox('text','string');
     setappdata(0,'hasbox',true);
end

us

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
msgbox us 17 May, 2008 10:45:09
code us 17 May, 2008 10:45:09
getappdata us 17 May, 2008 10:45:09
setappdata us 17 May, 2008 10:45:09
how can delete a msgbox in a function Frank Pezzulo 16 May, 2008 10:15:07
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics