We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › dinamyc variable creation
Page Index Toggle Pages: 1
dinamyc variable creation (Read 585 times)
dinamyc variable creation
Apr 1st, 2010, 3:35am
 
Hi to you all!

I´m new width processing and i was wondering how can i do this in proce55ing.

in actionscript i use this sintaxe:

for(i=0;i<10;i++){
this["name"+i]=10;
}

in processing how can i dinamicly create the variable name!!

thanks in advance!

vox
Re: dinamyc variable creation
Reply #1 - Apr 1st, 2010, 3:53am
 
April fool surely Smiley

Not in the same league as the Steve Jobs IPad joke though. Angry
Re: dinamyc variable creation
Reply #2 - Apr 1st, 2010, 4:08am
 
(doesn't look like a joke since it's not funny at all)

Array keys must be integers.

You may want to use hashmaps instead of arrays :
http://processing.org/reference/HashMap.html
Re: dinamyc variable creation
Reply #3 - Apr 1st, 2010, 4:21am
 
thanks for the response, but you didn't understand my question.

I want to create ten instances of a object with this names: name1, name2, name3... etc


for(int i=0; i<10; i++){
this["name"+i]=new myObject();
}

thanks
Re: dinamyc variable creation
Reply #4 - Apr 1st, 2010, 5:26am
 
Still looks a bit fishy to me, best one I've seen to today is the linux kernel, where they've turned the text upside down.http://userweb.kernel.org/~warthog9/april1/2010/

It would interesting to know how create the upside down text. I reckon it must have taken a lot of work all images etc were individually reversed (like it was genuine html conent!!!). Cheesy
Re: dinamyc variable creation
Reply #5 - Apr 1st, 2010, 6:03am
 
voxoff wrote on Apr 1st, 2010, 4:21am:
I want to create ten instances of a object with this names: name1, name2, name3... etc

I don't see the usefulness.
Just make an array name[] and use indexes in it.
Page Index Toggle Pages: 1