MathGroup Archive 2004

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

Search the Archive

RE: Package and options

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50427] RE: [mg50400] Package and options
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 3 Sep 2004 03:35:21 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Guillermo,

If it was part of a notebook, I would write your package something like the
following.

BeginPackage["Test1`"]

fexample1::"usage" =
    "fexample[x, opts] calculates (a + b) x where a and b are set by \
options.";

a::usage = "a is an option for fexample that sets its value.";

b::usage = "b is an option for fexample that sets its value.";

Begin["`Private`"]

Options[fexample1] = {a -> Global` A, b -> Global` B};
fexample1[x_, opts___Rule] :=
  (a + b) x /. {opts} /. Options[fexample1]

End[]
EndPackage[]


Then

?Test1`*

gives usage messges for a, b and fexample1 and

fexample1[x]
(A + B) x

Notice that I moved the Options statement to the Private section and I used
Global`A and Global`B to set the default values of a and b. Also you want to
start the usage message with the function name and arguments to get
automatic command completion when desired.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: Guillermo Sanchez [mailto:guillerm at aida.usal.es]
To: mathgroup at smc.vnet.net


Dear friends

Here is a example package:

(*Title : Package for testing options*)

BeginPackage["Test`Test1`"]

fexample1::"usage" = "Help example";

Options[fexample1] = {a -> A, b -> B}

Begin["`Private`"]

fexample1[x_, opts___Rule] :=
  (a + b) x /. {opts} /. Options[fexample1]

End[]

EndPackage[]

(*Now I request the package Help*)

?"Test`Test1`*"

(*They are shown not only the fexample1 help but the symbols used in
Options are also shown. How can I prevend that these symbols (a, A, b,
B} be shown.

Other general question:

When Options should be place inside of the private context?
Thanks.


Guillermo*)




  • Prev by Date: Re: Use of large memory
  • Next by Date: Re: Package and options
  • Previous by thread: Package and options
  • Next by thread: Re: Package and options