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 › reading data from text files
Page Index Toggle Pages: 1
reading data from text files (Read 845 times)
reading data from text files
Dec 16th, 2006, 9:17am
 
hi, is there anyway that processing reads data from text files? is there any special command or library for this?
many thanx

punchik
Re: reading data from text files
Reply #1 - Dec 16th, 2006, 10:36am
 
String[] data=loadStrings("data.txt");

That will give you one String per line of the text file data.txt put in the data subdirectory of your sketch.
Re: reading data from text files
Reply #2 - Dec 17th, 2006, 1:32am
 
yes, that works but theres a problem i found in this : why does my program doesnt change when i change the text file? it seems it just read the txt file when i compile the ejecutable file... but what about if i need that my txt file is always changing and i need that processing can read when something changes in the txt file...?
any hint?


Re: reading data from text files
Reply #3 - Dec 19th, 2006, 12:03pm
 
You could check each time the draw function is called for your data.
So each time you save your .txt file it'll be updated in your sketch.
(There might be a more gentle way of doing it tho)


Code:

void setup(){
//set things up here
}

void draw(){
//check for data
String[] data=loadStrings("data.txt");
println(data);
}

Re: reading data from text files
Reply #4 - Dec 19th, 2006, 12:28pm
 
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1166092114
Page Index Toggle Pages: 1