MathGroup Archive 1997

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

Search the Archive

Re: conditional package evaluation

  • To: mathgroup at
  • Subject: [mg6186] Re: [mg6170] conditional package evaluation
  • From: Allan Hayes <hay at>
  • Date: Thu, 27 Feb 1997 02:53:01 -0500
  • Sender: owner-wri-mathgroup at

murray at (Murray Eisenberg)
[mg6156] conditional package evaluation

> What are good ways to accomplish the following (in Mathematica 3.0)?
> When a package is loaded, a function in it is going to test the
> value of a certain Global` quantity, CheckMe.  If the value meets 
> the test, then the rest of the package is to be evaluated; other-
> wise it is not.
> The key thing is that I do not want the package's context to be
> created if the test is not met.  (Otherwise, the package's Private
> context could contain the function to make the test.)

A variant of your method works:

(* this is the package, not the notebook calling it! *)

   	f :: usage = "Message for exported function f";

      	(* other definitions here *)
   	f[x_] := "stuff";
   	Print["OK -- functions defined."];
   	, (*else*)
   	Print["check failed"];

Note. It is important to have a semicolon at end of each package  
expression so that new lines are not interpreted as multiplication

Allan Hayes
hay at

  • Prev by Date: Re: Information about non-symbol heads
  • Next by Date: Re: Using subscripts in variable _names_!!!
  • Previous by thread: Re: Information about non-symbol heads
  • Next by thread: Re: Using subscripts in variable _names_!!!