Question about Check[]
- To: mathgroup
- Subject: Question about Check[]
- From: sdoyle at fed.frb.gov
- Date: Tue, 2 May 89 09:46:39 CDT
[This is the first of a series of messages between Sean and me which basically discuss some differences between version 1.1 of Mathematica and a 1.2 beta release I am testing. I do not know the release date of 1.2 non-beta. -smc] I'm having some trouble getting Check[] to work with messages that I've defined. This would make error trapping much easier! When I enter the example from the manual (page 261), things work fine. Below is a similar example with a user-defined Message that doesn't work. This might be something I've missed in the manual, although examples of messages (such as for Convert on page 539) don't work with Check[] either. The desired result would be for the symbol `y' in Out[8] to have the value meaningless instead of `Null'. I've also tried using On[test::tosmall] without any difference in results. So... how can I create messages that Check[] will trap? Thanks! Sean Doyle Board of Governors of the Federal Reserve System 20 and Constitution, NW Mail Stop 76 Washington, DC 20551 (202) 452-2352 uucp: uunet!fed!m1swd00 , internet: sdoyle at fed.frb.gov ********************* Session below ************************ mqws2(115)% math SunMathematica (sun3.68881) 1.1 (September 14, 1988) [With pre-loaded data] by S. Wolfram, D. Grayson, R. Maeder, H. Cejtin, S. Omohundro, D. Ballman and J. Keiper Copyright 1988 Wolfram Research Inc. -- SunView graphics initialized -- In[1]:= test[x_]:= x /; x>0 In[2]:= test::toosmall = "The input to test is too small" Out[2]= The input to test is too small In[3]:= test[x_] := Message[test::toosmall] In[4]:= ??test test test/: test[x_] := x /; x > 0 test/: test[x_] := Message[test::toosmall] In[4]:= Messages[test] Out[4]= test::toosmall -> The input to test is too small In[5]:= test[5] Out[5]= 5 In[6]:= test[-4] test::toosmall: The input to test is too small In[7]:= y = Check[test[7],meaningless] Out[7]= 7 In[8]:= y = Check[test[-7],meaningless] test::toosmall: The input to test is too small In[9]:= y In[10]:= FullForm[y] Out[10]//FullForm= Null In[11]:=