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 › saving & loading txt
Page Index Toggle Pages: 1
saving & loading txt (Read 553 times)
saving & loading txt
Jan 4th, 2008, 6:54am
 
I finished a File A can output a (txt file)
And I would like to loading that same (txt file) at File B "on time"
Can I do that?? or I have to use another software to contor that??



p.s mac user

Re: saving & loading txt
Reply #1 - Jan 4th, 2008, 11:02am
 
loadStrings()

http://processing.org/reference/loadStrings_.html
Re: saving & loading txt
Reply #2 - Jan 5th, 2008, 7:58am
 
THANK YOU
the loading is on time

And another problem..

String lines[] = loadStrings("/data/time.txt");
 for (int d=0; d < lines.length; d++) {
   //println(lines[t]);

   if (lines[d] = 2) {  <<<this part have a problem he said (is not assignable)
   and i changed
  if (d =2) <<<then he said is not a boolean


Re: saving & loading txt
Reply #3 - Jan 5th, 2008, 8:58am
 
Code:


if (lines[d] = 2) { <<<this part have a problem he said (is not assignable)



Lines are of type String. You want lines[d].equals("2") or something similar.


Code:

if (d =2)


d = 2 is not a comparison. You'll want d==2.

http://processing.org/reference/assign.html
not the same as
http://processing.org/reference/equality.html
Re: saving & loading txt
Reply #4 - Jan 5th, 2008, 9:16am
 
thanks you again

I want

Code:
If (lines[d].equals("2")) {
   ellipse(200, 200, 40, 40);
}

but it show up at start

this is my original code
Code:
String lines[] = loadStrings("/data/time.txt");
//println("there are " + lines.length + " lines");
//println(lines);
 for (int i=0; i < lines.length; i++) {
   //println(lines[i]);
   //String str1  = lines[i];
   //println(str1);
   if (lines[i].equals("2.0")) {
     ellipse(20, 20, 40, 40);  
   }
 }
Re: saving & loading txt
Reply #5 - Jan 5th, 2008, 9:39am
 
I changed the code and it works

String lines[] = loadStrings("/data/time.txt");
//println("there are " + lines.length + " lines");
//println(lines);
for (int i=0; i < lines.length; i++) {
 //println(lines[i]);
 //String str1  = lines[i];
 //println(str1);
 if (lines[i].equals("2.0") == true) {
   ellipse(50, 50, 10, i);  
 }
}

And
If I run the saving file A and Loading file B at same time
file B won't happen anything

It only works if i run file A and close it then run file B  

I need to reflesh the txt on time
and read it on time



Page Index Toggle Pages: 1