help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string to variable?


From: Bill Denney
Subject: Re: string to variable?
Date: Mon, 4 Sep 2006 14:00:13 -0400 (EDT)

On Mon, 4 Sep 2006, the_verge wrote:

I was wondering if there is a way to assign a value to a variable, and then
construct a string with the same characters as the variable, and then use it
to access the value of the original variable.  For Example:

thing_a = 2;

x = "thing_a";
%code here to merge the string "thing_a" with the variable thing_a
x

My hope is that running this script would return

x = 2

Is there a way to do this?

It sounds like you're wanting to do something that would work better with structures (eval usually ends up causing headaches later). Might something like this work for you:

string = "thing_a";
value = 2;
x.(string) = value;

Now, x.thing_a is set equal to 2.

Bill

--
"You couldn't fill a 128-bit storage pool without boiling the oceans."
  -- Jeff Bonwick, http://www.sun.com/2004-0914/feature/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]