Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Test for On/Off (was: RE: Re: Manipulating Slot objects in Compile)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24689] Test for On/Off (was: RE: [mg24604] Re: Manipulating Slot objects in Compile)
  • From: Wolf Hartmut <hwolf at debis.com>
  • Date: Fri, 4 Aug 2000 01:19:11 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

improved at [Hartmut Wolf -2-]  


> -----Original Message-----
> From:	Wolf Hartmut 
To: mathgroup at smc.vnet.net
> Sent:	Tuesday, August 01, 2000 1:47 PM
> To:	'kuska at informatik.uni-leipzig.de'; Wolf Hartmut
> Cc:	mathgroup at smc.vnet.net
> Subject:	RE: [mg24604] Re: Manipulating Slot objects in Compile
> 
> 
> [Hartmut Wolf]  
> 
> There is a way to do that [find out if the message was prevoiusly on or
> off], regard:
> 
> In[7]:= Clear[cArg]
> 
> In[8]:= On[Part::"partd"]
> 
> In[9]:= wasOn = Check[cArg[[1]]; False, True, Part::"partd"]
> From In[9]:=
> Part::"partd": "Part specification \!\(cArg \[LeftDoubleBracket] 1 \
> \[RightDoubleBracket]\) is longer than depth of object."
> Out[9]= True
> 
> In[10]:= Off[Part::"partd"]
> In[11]:= Check[cArg[[1]]; False, True, Part::"partd"]
> Out[11]= False
> 
> In[12]:= If[wasOn, On[Part::"partd"]]
> 
> In[13]:= Check[cArg[[1]]; False, True, Part::"partd"]
> From In[13]:=
> Part::"partd": "Part specification \!\(cArg \[LeftDoubleBracket] 1 \
> \[RightDoubleBracket]\) is longer than depth of object."
> Out[13]= True
> 
> 
> 
[Hartmut Wolf -2-]  

The disadvantage of this method is that the error was really provoked,
sometimes this may not be easy to do (or may have other disadvantages). Now,
this is not neccessary, it suffices to issue the message! So

(here the message was on):
 
In[1]:=
wasOn = Check[Message[Part::"partd", "*** Test ***"]; False, True, 
    Part::"partd"]
>From In[1]:=
Part::"partd": "Part specification \!\(\"*** Test ***\"\) is longer than \
depth of object."
Out[1]= True

In[2]:= Off[Part::"partd"]

In[3]:= Message[Part::"partd", "*** silent operation ***"]

In[4]:= If[wasOn, On[Part::"partd"]]

In[5]:= Message[Part::"partd", "*** noisy operation ***"]
>From In[5]:=
Part::"partd": "Part specification \!\(\"*** noisy operation ***\"\) is \
longer than depth of object."


------------------
 
In[6]:= Off[Part::"partd"]

(here the message was set off):


In[7]:=
wasOn = Check[Message[Part::"partd", "*** Test ***"]; False, True,
Part::"partd"]
Out[7]= False

In[8]:= Off[Part::"partd"]

In[9]:= Message[Part::"partd", "*** silent operation ***"]

In[10]:= If[wasOn, On[Part::"partd"]]

In[11]:= Message[Part::"partd", "*** behaviour as before ***"]


So this is a general scheme!

-- Hartmut Wolf

  



  • Prev by Date: Re: getting module output in replace form
  • Next by Date: RE: Speeding up Replacement Rules
  • Previous by thread: Re: getting module output in replace form
  • Next by thread: RE: Speeding up Replacement Rules