PowerBasic Museum 2020-A

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Windows Script Runtime => Source Code => Scripting => FileSystemObject => Topic started by: José Roca on July 13, 2008, 11:35:33 PM

Title: ITextStream.ReadLine Method
Post by: José Roca on July 13, 2008, 11:35:33 PM


The following example illustrates the use of the ReadLine method.

JScript


function ReadLine()
{
   var fso, f;
   var ForReading = 1, ForWriting = 2;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.OpenTextFile("c:\\testfile.txt", ForWriting, true);
   f.Write("Hello World!");
   f.Close();
   f = fso.OpenTextFile("c:\\testfile.txt", ForReading);
   return(f.ReadLine);
}


VBScript


Function ReadLine
   Const ForReading = 1, ForWriting = 2
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.Write "Hello world!"
   f.Close
   Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
   GetColumn = f.ReadLine
End Function


PowerBASIC


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

END FUNCTION