The following example illustrates the use of the
ReadAll method.
JScript
function ReadAll()
{
var fso, f
var ForReading = 1, ForWriting = 2;
fso = new ActiveXObject("Scripting.FileSystemObject")
f = fso.OpenTextFile("c:\\textfile.txt", ForWriting, true)
f.WriteLine("Hello world!");
f.WriteLine("JScript is fun");
f.Close();
f = fso.OpenTextFile("c:\\textfile.txt", ForReading);
return(f.ReadAll);
}
VBScript
Function ReadAll
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!" & vbCrLf & "VBScript is fun!" & vbCrLf
f.Close
Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
GetLine = f.ReadAll
End Function
PowerBASIC
FUNCTION ReadAll () 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!" & $CRLF & "VBScript is fun!" & $CRLF)
f.Close
f = fso.OpenTextFile(UCODE$("c:\testfile.txt"), %IOMode_ForReading)
FUNCTION = ACODE$(f.ReadAll)
f.Close
END FUNCTION