Dynamic Variable Name?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/04/2011 at 00:37, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
Hi everyone.Is there a way to dynamically construct a variable name?
E.g. I have variables Title1, Title2, Title3, and so on (it's a big list).
I want to use a loop to set each Title variable rather than manually specify each Title.
Is there a way for me to construct the variable name and then assign a value to it?
Just to clarify, arrays won't work for me because these Title(n) variables are outputs on an Xpresso COFFEE node.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/04/2011 at 01:58, xxxxxxxx wrote:
No, that's not possible.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/04/2011 at 02:47, xxxxxxxx wrote:
Hello Eikonoklastes,
Because all your outputs are defined in the node, you can do this:
Output(number, data) { switch (number) { case 0: Output0=data; case 1: Output1=data; case 2: Output2=data; case 3: Output3=data; default: break; } } main() { var i; var myArray = new(array,4); myArray[0] = 123; myArray[1] = 0.456; myArray[2] = 11.1; myArray[3] = -234; for(i=0; i<4;i++) { Output(i, myArray[i]); } }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/04/2011 at 03:21, xxxxxxxx wrote:
This is possible in Python. You can iterate over ports of a node(to get the name) or any variable in any scope and read/set it's values.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/04/2011 at 04:10, xxxxxxxx wrote:
Just some samplecode (Python) :
\>>>locs = locals() \>>>for i in range(20) : locs['number%s'%i] = i \>>>print number1,number5,number17,number19 1 5 17 19 \>>>print number20 <type 'exceptions.NameError'> name 'number20' is not defined <traceback object at 0x5fca7d4>