Core Function FileReadLines

From Sputnik Wiki
Revision as of 11:05, 9 November 2011 by UberFoX (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
FileReadLines( <file> )

Contents

Description

Read all lines of text from a previously opened text file (Or specify a name of a file).

Parameters

file

A variable containing the File handle OR a name of a file to open.

Return Value

Success: Returns an array of all lines

Failure: Returns 0 if error occurs.

Remarks

Trailing newlines "\n" and "\r" will be removed from the end of the returned lines automatically.

Example

For $Line In FileReadLines( "MyFile.txt" )
	println( "Line is: " . $Line )
Next

Another :

$Lines = FileReadLines( "MyFile.txt" )
 
For $Line In $Lines
	println( "Line is: " . $Line )
Next

Heres it in use with a File Handle :

$File = FileOpen("MyFile.txt", "r")
If isObj($File, "file") Then
	For $Line In FileReadLines($File)
		println( "Line is: " . $Line )
	Next
	FileClose( $File )
EndIf
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox