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

Re: [sc-users] dynamic variable values



> i'm trying to dynamically access the value of a variable (identifier)
> by interpreting a string and a number as demonstrated below.

> 	var vview_0 = 20;
> 	("vview_"++0).asString.interpret.postln;

The variable is out of the interpreter's scope in your example. Either

(
var index = 0;
("var vview_" ++ index.asString ++ " = 20; vview_" ++
   index.asString).interpret.postln;
)

or

(
~vview_0 = 20;
("~vview_" ++ 0.asString).interpret.postln;
)

will work.

It's much better to create a data structure if you can.