Re: Symbols, names, objects: kludge
- To: mathgroup at smc.vnet.net
- Subject: [mg6585] Re: Symbols, names, objects: kludge
- From: haberndt at dnai.com (Harald Berndt)
- Date: Fri, 4 Apr 1997 02:11:35 -0500 (EST)
- Organization: DNAI ( Direct Network Access )
- Sender: owner-wri-mathgroup at wolfram.com
In article <5hdbcn$ds4 at smc.vnet.net>, murray at math.umass.edu (Murray
Eisenberg) wrote:
> I found one method that works -- sort of, and sometimes -- but which I
> don't fully understand:
>
> store[varname_String, dataname_String] :=
> ToExpression[StringJoin[Sequence@@{varname,"=",dataname}]]
>
> 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).
>
Murray:
Have you tried converting everything ToExpression[] and evaluating before
making the assignment? Like
Evaluate[ToExpression[varname]] = Evaluate[ToExpression[dataname]]
This gets parsed and evaluated OK. Unfortunately,
Evaluate[ToExpression[#]]& /@ {"y", "=", "t"}]
doesn't seem to work.
Best,
--
Harald Berndt, Ph.D. Research Specialist,
Voice: 510-652-5974 Consultant
FAX: 510-215-4299