MathGroup Archive 2001

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

Search the Archive

Re: Serious bug in MatchQ causes crashes and incorrect results


Hi,

> The reason I use 'Abort[]' is to stop the Kernal from generating
> hundreds of useless error messages after I know something has failed.
> I have used it quite a bit on both the Mac and under Solaris with no
> problems.  I sometimes do use 'Throw[]'.

I still can't understand how the functions are written. If
some test failed the function should terminate smooth with
some nice message.

> 
> The file names are generally being entered manually, not returned by
> 'FileNames[]' so they do need to be checked. 

And a

getFile[fname_String] /; 

> The approach of checking
> argument patterns and aborting if they don't match came out of
> difficulty in defining both complex patterns and default values for the
> arguments.  I still don't understand the syntax for some of the
> suggested solutions.  If I could define complex patterns with default
> arguments could I then define a version of the function to match all
> invalid argument patterns such as:
> 
> getFile[___]:= CompoundExpression[Message[]; Throw[]/Abort[] ];  ?
> 
>                                 -Jeff DuMonthier

What is so complicate to define a function
like

getFile[]:=getFile["someSupidFilename.dat"]
getFile[fname_String]/; StringMatchQ[fname,"*.dat"]:=Print["Filename:
",fname]


or what is so difficult to make a test like

getFile[fname_String, filepatt_, dirs_:{$HomeDirectory}] :=
  Module[{flst},
    flst = 
      Select[FileNames[filepatt, dirs], StringMatchQ[#, "*" <> fname]
&];
    If[flst === {},
      Message[getfile::notfound, fname];
      Return[$Failed]
      ];
    ByteCount /. FileInformation[fname]
    ]


Can you tell me "what" you don't understand ?

Regards
  Jens


  • Prev by Date: Re: Special Matrix
  • Next by Date: RE: Graphics Bug (or anomaly anyway)
  • Previous by thread: Re: Serious bug in MatchQ causes crashes and incorrect results
  • Next by thread: Notebooks do not display correctly in 1024X768