Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: How to convert string to variable name

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39866] Re: How to convert string to variable name
  • From: Bob Harris <NspamITmeLION at MINDnotSPRING.COM>
  • Date: Sun, 9 Mar 2003 05:28:44 -0500 (EST)
  • References: <b49n66$fdc$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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