Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

If and symbol creation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90376] If and symbol creation
  • From: Mark Fisher <particlefilter at gmail.com>
  • Date: Tue, 8 Jul 2008 02:23:13 -0400 (EDT)

I'd like to use an If statement to conditionally load a package and
make some assignments, but I'm running into a problem with
CompoundExpression. Here's an example:

(Needs["Calendar`"]; fun = DayOfWeek)

This creates DayOfWeek in the Global context before the effect of the
Needs statement takes effect. The same thing happens in an If
statement. BTW, DayOfWeek gets put in the Global context even in the
following:

If[True, 1, Needs["Calendar`"]; fun = DayOfWeek]

Anyway, do people do to avoid this problem?


--Mark



  • Prev by Date: Multiple Executions of .nb file
  • Next by Date: How to make variable have package scope but not global scope.
  • Previous by thread: Re: Multiple Executions of .nb file
  • Next by thread: Re: If and symbol creation