Author Topic: ITextStream.WriteLine  (Read 2853 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2517
  • User-Rate: +209/-0
  • Gender: Male
ITextStream.WriteLine
« on: July 13, 2008, 11:16:57 PM »

The following example illustrates the use of the WriteLine method.

JScript

Code: [Select]
var fso, f;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.CreateTextFile("c:\\testfile.txt", true);
f.WriteLine("This is a test.");
f.Close();

VBScript

Code: [Select]
Function WriteLineToFile
   Const ForReading = 1, ForWriting = 2
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.WriteLine "Hello world!"
   f.WriteLine "VBScript is fun!"
   Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
   WriteLineToFile = f.ReadAll
End Function

PowerBASIC

Code: [Select]
FUNCTION WriteLineToFile () AS STRING

   LOCAL fso AS IFileSystem
   LOCAL f AS ITextStream

   fso = NEWCOM ("Scripting.FileSystemObject")
   f = fso.OpenTextFile(UCODE$("c:\testfile.txt"), %IOMode_ForWriting, %VARIANT_TRUE)
   f.WriteLine UCODE$("Hello world!")
   f.WriteLine UCODE$("VBScript is fun!")
   f.Close
   f = fso.OpenTextFile(UCODE$("c:\testfile.txt"), %IOMode_ForReading)
   FUNCTION = ACODE$(f.ReadAll)
   f.Close

END FUNCTION