MathGroup Archive 2003

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

Search the Archive

Re: Options for my own Packages?

"Steven T. Hatton" <hattons at> wrote in message news:<bnlidb$p92$1 at>...
> Can I create and use options in my own packages?  I've seen comments in the
> help documentation that say "built-in functions" have options.  Here's an
> example of what I want.  I created a class called curveGrid, which has data
> and methods for generating a coordinate grid defined by a mapping function
> passed to the constructor.  I would like to be able to set an option that
> changed the default color of all instances of this class.
> Is there a way to accomplish this so that I can do something like
> SetOptions[curveGrid,name->value, name2->value2...]?

Here is an example after the book "Programming in Mathematica" by Roman Maeder:

In[1]:= Options[f] = {Opt1 -> True, Opt2 -> True};

f[n_, opts___Rule]:=
Module[{opt1, opt2},
   opt1 = Opt1 /. {opts} /. Options[g];
   opt2 = Opt2 /. {opts} /. Options[g];



In[2]:= f[1, Opt2 -> False]


  • Prev by Date: Re: Full error messages?
  • Next by Date: Re: Options for my own Packages
  • Previous by thread: RE: Options for my own Packages?
  • Next by thread: Mathematica Wish-List