• Welcome to Jose's Read Only Forum 2023.
 

ITextStream.WriteBlankLines

Started by José Roca, July 13, 2008, 11:19:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example illustrates the use of the WriteBlankLines method.

JScript


function WriteBlankLinesToFile()
{
   var fso, f, r;
   var ForReading = 1, ForWriting = 2;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.OpenTextFile("c:\\testfile.txt", ForWriting, true);
   f.Write("Hello world!");
   f.WriteBlankLines(2);
   f.Write("JScript is fun!");
   f.Close();
   f = fso.OpenTextFile("c:\\testfile.txt", ForReading);
   r = f.ReadAll();
   return(r);
}


VBScript


Function WriteBlankLinesToFile
   Const ForReading = 1, ForWriting = 2
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.WriteBlankLines 2
   f.WriteLine "Hello World!"
   Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
   WriteBlankLinesToFile = f.ReadAll
End Function


PowerBASIC


FUNCTION WriteBlankLinesToFile () 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.WriteBlankLines 2
   f.Write UCODE$("Hello world!")
   f.Close
   f = fso.OpenTextFile(UCODE$("c:\testfile.txt"), %IOMode_ForReading)
   FUNCTION = ACODE$(f.ReadAll)
   f.Close

END FUNCTION