• Welcome to Jose's Read Only Forum 2023.
 

ITextStream.AtEndOfStream Property

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example illustrates the use of the AtEndOfStream property.

JScript


function ReadEntireFile(filespec)
{
   var fso, f, s, ForReading;
   ForReading = 1, s = "";
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.OpenTextFile(filespec, ForReading, false);
   while (!f.AtEndOfStream)
      s += f.ReadLine( );
   f.Close( );
   return(s);
}


VBScript


Function ReadEntireFile(filespec)
   Const ForReading = 1
   Dim fso, theFile, retstring
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set theFile = fso.OpenTextFile(filespec, ForReading, False)
   Do While theFile.AtEndOfStream <> True
      retstring = restring & theFile.ReadLine
   Loop
   theFile.Close
   ReadEntireFile = retstring
End Function


PowerBASIC


SUB ReadEntireFile (BYVAL strFileSpec AS STRING)

   LOCAL fso AS IFileSystem
   LOCAL theFile AS ITextStream
   LOCAL restring AS STRING

   fso = NEWCOM ("Scripting.FileSystemObject")
   theFile = fso.OpenTextFile(UCODE$(strFileSpec), %IOMode_ForReading, %VARIANT_FALSE)
   DO
      IF theFile.AtEndOfStream THEN EXIT DO
      restring = retstring & theFile.ReadLine
   LOOP
   theFile.Close
   FUNCTION = restring

END SUB