Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Module and database combined

  • To: mathgroup at
  • Subject: [mg48237] Module and database combined
  • From: Goyder Dr HGD <h.g.d.goyder at>
  • Date: Wed, 19 May 2004 02:42:14 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

What is the best way of mixing modules and databases so that one can
preserve the flexibility of data structures in a database and avoid the
clash of symbols as provided by a module?

Below is an example where I first construct a database in the global
environment where data may be added and withdrawn with no difficulty.

I then try to read the database into a module but, quite correctly, the
module prevents access to the data by setting up unique symbols.

The problem gets worse if an attempt is made to generate a unique database
within a module and then to work with this database in other modules.

DataBase[theNumber] = 1; 
DataBase[theRule] = PlotRange -> {{0, 1}, {0, 1}}; 
DataBase[theList] = {1, 2, 3}; 

{DataBase, DataBase[theNumber], DataBase[theRule], DataBase[theList]}

{DataBase, 1, PlotRange -> {{0, 1}, {0, 1}}, {1, 2, 3}}

f[db_] := Module[{theNumber, theRule, theList}, p = {db, db[theNumber],
db[theRule], db[theList]}; Print[p]]


{DataBase, DataBase[theNumber$17], DataBase[theRule$17],

g := Module[{DataBase, theNumber, theRule, theList}, DataBase[theNumber] =
    DataBase[theRule] = PlotRange -> {{10, 20}, {10, 20}}; DataBase[theList]
= {10, 20, 30}; f[DataBase]]


{DataBase$18, DataBase$18[theNumber$19], DataBase$18[theRule$19],

As may be seen the unique number given to the database and to the other
symbols by a module correctly prevents a clash of symbols. However, I want
to withdraw data from a database within a module environment, use it within
a module and not change global values. How do I do this?

Hugh Goyder

This message has been scanned for viruses and
dangerous content by the Cranfield MailScanner, and is
believed to be clean.

  • Prev by Date: Re: Delay DE's
  • Next by Date: RE: Re: Precision of output
  • Previous by thread: Re: From C/C++ to Mathematica?--> 5.0 documentaion?
  • Next by thread: evolution matrix and ODEs, i think....