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 › Loading string in class
Page Index Toggle Pages: 1
Loading string in class? (Read 533 times)
Loading string in class?
Aug 10th, 2009, 12:47am
 
/////////////////////////////////////////////MAIN
import processing.opengl.*;

int sceneW = 1000;
int sceneH = 1000;


slogan monSlogan = new slogan();

void setup(){
 size(sceneW,sceneH,OPENGL);

}

void draw(){

}
////////////////////////////MY CLASS slogan
class slogan{

 slogan(){
   String lines[] = loadStrings("slogan1.txt");
 
 
 }

}

It says that "The file "slogan1.txt" is missing or inaccessible", but i have this file in UTF-8 in my data folder.

What's wrong please?
Thank you very munch.

Re: Loading string in class?
Reply #1 - Aug 10th, 2009, 2:03am
 
You have to call loadStrings after the sketch path has been initialized. so a possible solution would be:

Code:

Slogan mySlogan;

void setup() {
 mySlogan = new Slogan();
}

class Slogan {
 Slogan() {
   String lines[] = loadStrings("slogan1.txt");
 }
}


another possibility would be:

Code:

Slogan mySlogan = new Slogan();

void setup() {
 mySlogan.load();
}

class Slogan {
 void load() {
   String lines[] = loadStrings("slogan1.txt");
 }
}
Re: Loading string in class?
Reply #2 - Aug 10th, 2009, 2:36am
 
yes, i understand,

thank you very munch for your help.

Smiley
Page Index Toggle Pages: 1