Re: Options in user-defined functions...
- To: mathgroup at smc.vnet.net
- Subject: [mg60343] Re: [mg60332] Options in user-defined functions...
- From: Manuel Schmidt <Manuel.Schmidt at physik.uni-wuerzburg.de>
- Date: Wed, 14 Sep 2005 03:27:11 -0400 (EDT)
- References: <200509131007.GAA09758@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
try this code:
Options[func]={option1->False,option2->True};
func[x1_,x2_,optns___]:=Block[{someInternalVariables,o1Flag,o2Flag},
o1Flag=option1/.{optns}/.Options[func];
o2Flag=...
]
Regards,
Manuel
On Tue, 2005-09-13 at 06:07 -0400, Daniele Lupo wrote:
> Hi to all.
>
> I've a little problem with a function. I've defined it in this way:
>
> fun[x_,op1_:1,op2_:2,op3_:3]:=
> Module[{....},f1[x,op1],f2[x,op2],f3[x,op3]]
>
> So, when I use it, ops have their default values.
>
> It works, but I'd like to use option; this why, if I want to change only
> op3, I must to write every argument when I call the function, while I'd
> like to write something like this:
>
> fun[x,op3->4]
>
> how can I do it?
>
> Thanks for you answers
>
> Daniele
- References:
- Options in user-defined functions...
- From: Daniele Lupo <danwolf80_no_spam_@libero.it>
- Options in user-defined functions...