MathGroup Archive 1997

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

Search the Archive

Re: Symbols, names, objects: kludge

  • To: mathgroup at
  • Subject: [mg6533] Re: [mg6517] Symbols, names, objects: kludge
  • From: Allan Hayes <hay at>
  • Date: Mon, 31 Mar 1997 23:01:33 -0500 (EST)
  • Sender: owner-wri-mathgroup at

murray at (Murray Eisenberg)
[mg6517] Symbols, names, objects: kludge

In an earlier posting, I asked how to define a function
store[varname_String, dataname_String] that causes a variable to be
created whose name is given by the string used as first argument and
which assigns as the value of that new variable the value of the
object whose name is given by the string used as the second argument.
For example,

   x = 99;
   store["myx", "x"]

should mean that an input


now produces


as output.

I found one method that works -- sort of, and sometimes -- but which I
don't fully understand:

   store[varname_String, dataname_String] :=

Unfortunately, I need to use such a function store inside a Module,
like this:

   wrapper[shortname_String] := Module[{temp},
      temp = ...... (* value created here *) ;
      store["new"<>shortname, "temp"];

and now, because temp is a local variable in the Module, the whole
thing breaks down (assigning the SYMBOL temp as the value of the
new... variable).

With your definition
  store[varname_String, dataname_String] :=

How about this sort of thing --

wrapper[shortname_String] := Module[{temp},
      temp = 3 ;
      store["new"<>shortname, ToString[temp]]


Allan Hayes
hay at

  • Prev by Date: Re: NDSolve problem
  • Next by Date: Fwd: Symbols, names, objects
  • Previous by thread: Re: Symbols, names, objects
  • Next by thread: Re: Symbols, names, objects: kludge