maxtuckett
YaBB Newbies
Offline
Posts: 4
question re : file reading w/ loadstrings()
Oct 26th , 2007, 11:40pm
Hi there. I'm working on a research project, and have been asked to get Second Life and processing to communicate. I have successfully gotten processing to write a file with a php script, and then access it from SL (with slhttprequest), but I am having trouble doing the reverse. This part of this very simple experiment works as such : There are three coloured toruses in Second Life, that when I click any of them, accesses a php script which writes either a 1,2 or a 3 to a text file, depending on which torus clicked. (it writes this file to the /data/ directory of my sketch) The file is called sl2proc.txt Then, I have this simultaneous Processing sketch running, where I attempt to access the file with the loadStrings function. The thing is : It works the first time, ie. When I load my browser (firefox) up, and load the sketch url, it accesses the file and pulls the proper data. Then, when I change the data in the textfile (either through clicking a torus, or manually editting the text file), suddenly Processing wont recognize the change (It tries to update every 3 seconds). It continues to tell me that the data it has pulled from the file is the same (by not changing the colour indicator, and via a println). If I close firefox at that point, and reopen it, the sketch now recognizes the change and updates accordingly. Just closing the sketch window and/or reloading the Processing url doesn't fix it. I need to completely close firefox to have it access the file anew. It seems like, when I first use Loadstrings, the Java runtime environment puts the textfile in memory, and refuses to shake it, despite the actual change in the file. Is there some way to address this? To get processing to recognize that the file has been modified? to forcibly close the filestream? http://caferisko.ca/TEST/test3/sl2proc/applet/index.html // this is the applet http://slurl.com/secondlife/Tkachiev/91/211/601 // this is where the modifying torus are // they are on a platform 601 ft in the air. Any help would be greatly appreciated thanks! max