lowell_j
YaBB Newbies
Offline
Posts: 1
loadStrings from output txt
Jan 27th , 2008, 9:38pm
hello all! i am fairly new to processing and my programming skills lack to go any further on this without your help. so, thing is: i am retrieving data from a website (http://www.iraqbodycount.org/database), which causes a sewing machine connected to an arduino, to do one stitch per dot (".") - for each reported case of death. this is as far is i got: ------------------------------------------------------------ import processing.serial.*; import prohtml.*; HtmlList htmlList; Serial myPort; PrintWriter output; String URL = "http://www.iraqbodycount.org/database"; String tempstring; int range; void setup(){ size(100,100); htmlList = new HtmlList(URL); output = createWriter("range.txt"); //myPort = new Serial(this, Serial.list()[1], 19200); } void draw(){ for (int i=0; i<htmlList.pageList.size(); i++){ String ts = htmlList.pageList.get(i).toString(); int t = ts.indexOf("ibc-range"); if(t > -1){ tempstring = htmlList.pageList.get(i+3).toString(); } } range = int(tempstring.substring(0,5)); // println(range); for (int i=1; i<=range; i++) { println("."); println(((range-i)-range)*(-1)); output.flush(); output.println(((range-i)-range)*(-1)); //myPort.write("."); delay(1000); } } my problems: - my draw function loops continuously. it should stop, as it reaches the current state, which is 88100, and just add +1 each time as the counter is updated. - i need an output file, on how many stitches are already done. my solution, the PrintWriter output, won't work i think, cause each time the program runs, the file would be created once again. how should i do that? - then i need to import the data from that file and turn it into a variable, "cnt", which holds the information, on how many stitches are done so far. - by loadStrings? - it would replace the i in the for loop with (i=cnt; i<=range; i++). but how would i uptade "cnt" after the loop? - what then leads me back to the output file and how it should be created. that's it. i know, there's quite a lot i don't know, but any comment on how to get this run properly, would be very very much appreciated. very thanks in advance. lowell.