The following example illustrates the use of the
Line property.
JScript
function GetLine()
{
var fso, f, r
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);
r = f.ReadAll();
return(f.Line);
}
VBScript
Function GetLine
Const ForReading = 1, ForWriting = 2
Dim fso, f, ra
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)
ra = f.ReadAll
GetLine = f.Line
End Function
PowerBASIC
FUNCTION GetLine () AS LONG
LOCAL fso AS IFileSystem
LOCAL f AS ITextStream
LOCAL ra AS STRING
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)
ra = f.ReadAll
FUNCTION = f.Line
f.Close
END FUNCTION