Door Games Unlimited

Welcome, Guest.


Subject: Writing to a text file Date: Thu Feb 06 2014 23:55:22
From: Lab Rat To: All

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();

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.

Any code suggestions would be welcome!

Thanks,

Lab Rat.


---
 ■ Synchronet ■ Toxic Laboratory BBS - Birmingham, UK - toxicbbs.com

Previous Message       Next Message
Replies: Writing to a text file (Digital Man)Writing to a text file (MCMLXXIX)Writing to a text file (Deuce)