MathGroup Archive 2008

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

Search the Archive

Help with Check Function Arguments & Options

  • To: mathgroup at
  • Subject: [mg87255] Help with Check Function Arguments & Options
  • From: Andrew Beveridge <acbev at>
  • Date: Sat, 5 Apr 2008 04:25:29 -0500 (EST)

I would like to thank everyone who has previously responded to my 
posts. Your advice has helped greatly.

I have a couple of final questions.

I am writing a package file and would like to do some argument and 
option checking if possible; that is check the number of arguments 
and see if there are unknown options.

If my function has no options I think I can do this.

f[x_,y_] := x + y
f[args___] := If[Length[{args}] != 2, Message[f::"argrx", f, 
Length[{args}], 2]; Return[$Failed]]

This type of check has been posted to the message board before.

My question is assume that f[x,y] has multiple options, that is
Options[f] = {opt1 -> 1, opt2 -> True}, etc

How do I check if the user entered the correct options?

Thanks again for all of your help.


Andrew C Beveridge
MS M888
Los Alamos National Laboratory
Los Alamos, NM  87545

e-mail: acbev at

  • Prev by Date: Re: Colored Output
  • Next by Date: Re: Colored Output
  • Previous by thread: Re: same input ... different results???
  • Next by thread: Re: Help with Check Function Arguments & Options