Re: Help with Check Function Arguments & Options
- To: mathgroup at smc.vnet.net
- Subject: [mg87292] Re: [mg87255] Help with Check Function Arguments & Options
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 6 Apr 2008 06:46:37 -0400 (EDT)
- Reply-to: hanlonr at cox.net
In version 6 use FilterRules. In earlier versions use Utilities`FilterOptions`
Bob Hanlon
---- Andrew Beveridge <acbev at lanl.gov> wrote:
> 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.
>
> Regards,
> Andrew
>
> Andrew C Beveridge
> MS M888
> Los Alamos National Laboratory
> Los Alamos, NM 87545
>
> 505-665-2092
> e-mail: acbev at lanl.gov
>
>