FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   loadStrings()?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: loadStrings()?  (Read 445 times)
D_emon
Guest
Email
loadStrings()?
« on: Jul 1st, 2004, 7:31am »

Hello,everyone.
I want to read the data in a file and make it reflected in animation.
And I want to also make the updated data reflected.
But, while running sketch, even if it updates a file, it will be read as a file before updating.
A test program is put on below.
"test.txt" is in a "data" holder and one number is written.
What should I do?
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int count=0;
   
void setup(){
  size(200,200);
  framerate(1);
}
 
void loop(){
  count+=1;
  if(count == 5){
    String number[] = loadStrings("test.txt");  
    println(number[0]);
    count=0;
  }
}  
 
kevinP

Email
Re: loadStrings()?
« Reply #1 on: Jul 2nd, 2004, 10:14am »

One number is written? To the file??
 

Kevin Pfeiffer
D_emon
Guest
Email
Re: loadStrings()?
« Reply #2 on: Jul 4th, 2004, 1:36pm »

Yes, only one number is written in the file.
Although I wanted to treat many numbers in fact, I tried on one number first.
However, the updated number wasn't read.
 
TomC

WWW
Re: loadStrings()?
« Reply #3 on: Jul 4th, 2004, 1:45pm »

I *think* that files in the data directory are included in the jar file when the applet is compiled. That means that changes to the data directory won't be recognised until you recompile.
 
You should be able to use regular Java to load/save things whilst you're running your application though (if you don't want to carry things from one time to the next, you should probably use the temp folder, which I think Java can find). You can't use Processing's convenient methods which look in the data directory, because they aren't actually looking in there, they're looking in the jar file.
 
Hope that makes sense.
 
Update: also note that saveStrings does not write to the data folder, it writes to the main Processing folder.  You can use a specific path for saveStrings and loadStrings (contrary to what I just said, that means you don't have to use regular Java if you don't want to, you just have to get the paths to match).
« Last Edit: Jul 4th, 2004, 1:47pm by TomC »  
D_emon
Guest
Email
Re: loadStrings()?
« Reply #4 on: Jul 6th, 2004, 3:51am »

Thank you for your advice!
I solved by using a specific path. I'm sorry to be an elementary mistake.I should study regular Java as you say.
 
TomC

WWW
Re: loadStrings()?
« Reply #5 on: Jul 6th, 2004, 11:55am »

When I said "you should be able to", I meant that "it should be possible to". I wasn't saying that "you should have the ability to".  Learn Java if you want to, not because I say so
 
Oh, and it wasn't an elementary mistake at all... I've made the same mistake myself!
 
Pages: 1 

« Previous topic | Next topic »