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 › joining strings to make variables!
Page Index Toggle Pages: 1
joining strings to make variables?!? (Read 529 times)
joining strings to make variables?!?
Nov 17th, 2005, 8:13pm
 
How can I make this work? essentially I need the equivalent of the flash eval command but i don't see an equivalent in processing

where framemask are Pimages defined at the start of the sketch.

Code:

for (int i=totalFrames; i > 1; i--) {
"framemask" + i = "framemask" + (i-1).get();
}


cheers
niall
Re: joining strings to make variables?!?
Reply #1 - Nov 17th, 2005, 10:58pm
 
You need to use arrays, since you can't do things like eval().

You'll need something like this:

Code:
PImage[] framemask;

void setup()
{
...
framemask=new PImage[totalFrames];
for(int i=0;i<totalFrames;i++)
{
framemask[i]=loadImage(..); // or however you're creating the images
}
}

void draw()
{
for(int i=totalFrames;i>1;i--)
{
framemask[i]=framemask[i-1];
}
}
Re: joining strings to make variables?!?
Reply #2 - Nov 18th, 2005, 12:16am
 
ah of course -
I never thought of using the PImage as an array in setup.

makes  sense now!

Cheers for that, I'll give it a whirl and see how it goes.

Niall
Page Index Toggle Pages: 1