• Welcome to Jose's Read Only Forum 2023.
 

IFileSystem.OpenTextFile Method

Started by José Roca, July 14, 2008, 02:17:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



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