Re: Writing to a text fileã By: Lab Rat to All on Thu Feb 06 2014 11:55 pmãã > Hi all,ã >ã > Unfortunately, Javascript isn't my first (programming) language and I'mã > struggling to get to grips with creating a simple plain text file from aã > script. I've spent hours staring at the JS Object Model Referenceã > (
http://synchro.net/docs/jsobjs.html) and I just cannot work it out.ã >ã > This is what I've got so far:ã >ã > var f = new File('test.txt');ã > file.open('w');ã > file.writeln('Line 1');ã > file.writeln('Line 2');ã > file.close();ãã"file" is not defined in that example. I think you meant to write f.open(), ãf.writeln(), and f.close().ãã > I've tried the file.open(file_exists(file.name) ? 'r+':'w+'); lineã > mentioned in the documentation and I just cannot get this to work.ããReplacing "file" with "f" in your example seems to work fine for me (creates a ãfile "test.txt" with the 2 lines you have specified).ãã > Any code suggestions would be welcome!ããYour code looks fine (except for the file/f confusion I mentioned). It might be ãconfusing to you that the file being created/written will be located in your ãSynchronet "ctrl" directory since you did not specify a full pathname for the ãfile.ããThere are many examples in the exec/*.js files which open/modify files. You ãcould look at those for some tips or inspiration as well.ãã digital manããSynchronet "Real Fact" #3:ãSynchronet version 3 is written mostly in C, with some C++, x86 ASM, and Pascal.ãNorco, CA WX: 50.6øF, 92.0% humidity, 2 mph W wind, 0.12 inches rain/24hrsã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã