Author Topic: ITextStream.AtEndOfStream Property  (Read 2502 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2524
  • User-Rate: +209/-0
  • Gender: Male
ITextStream.AtEndOfStream Property
« on: July 13, 2008, 11:52:41 PM »

The following example illustrates the use of the AtEndOfStream property.

JScript

Code: [Select]
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

Code: [Select]
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

Code: [Select]
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