The following code illustrates the use of the
OpenTextFile method to open a file for appending text:
JScript
var fs, a, ForAppending;
ForAppending = 8;
fs = new ActiveXObject("Scripting.FileSystemObject");
a = fs.OpenTextFile("c:\\testfile.txt", ForAppending, false);
...
a.Close();
VBScript
Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
f.Write "Hello world!"
f.Close
End Sub
PowerBASIC
LOCAL fso AS IFileSystem
LOCAL f AS ITextStream
fso = NEWCOM "Scripting.FileSystemObject"
f = fso.OpenTextFile(UCODE$("c:\testfile.txt"), %IOMode_ForWriting, %VARIANT_TRUE)
f.Write ACODE$("Hello world!")
f.Close