MathGroup Archive 2003

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

Search the Archive

Re: How to convert string to variable name


I wrote:
>> ... for a given string, how can I assign to the variable whose name is
>> defined by that string?

and Hermann Schmitt replied:
> I would do it the following way:
> ToExpression["z = ....."];

Thanks, that appears to be what I want.  I just have to build a string that
contains the entire assignment.

A couple people suggested using Symbol[], but I don't see how that would
work.  For example,

    Symbol["x"] = 13

doesn't create a symbol x with value 13.  Instead, it simply produces an
error message informing me that "Tag Symbol in Symbol["x"] is Protected."

Thanks,
Bob H



  • Prev by Date: Re: nth differences
  • Next by Date: Re: nth differences
  • Previous by thread: Re: How to convert string to variable name
  • Next by thread: Re: Re: How to convert string to variable name