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 › using int variable as filename to loadImage
Page Index Toggle Pages: 1
using int variable as filename to loadImage (Read 616 times)
using int variable as filename to loadImage
Dec 22nd, 2009, 6:34pm
 
Hi,
I am trying to use an integer variable as the filename to load an image but it says the file is missing or inaccessible.

Here is what I'm doing:

int test =1;
one = loadImage(str(test),"jpg");

However if I use:

one = loadImage("1.jpg");

It works no problem, what am I doing wrong?
Thanks for any help
Re: using int variable as filename to loadImage
Reply #1 - Dec 22nd, 2009, 8:50pm
 
You may need to do this:
one=loadImage(str(test)+".jpg");
This way the argument you pass to loadImage is a complete file name with the extension.
Page Index Toggle Pages: 1