Function Reference


FileReadToArray

Reads the specified file into an array.

FileReadToArray ( "filehandle/filename" )

Parameters

filehandle/filename The handle of a file, as returned by a previous call to FileOpen(). Alternatively you may use a string filename as the first parameter.

Return Value

Success: a 1 dimension array containing one line of text per element and @extended set to the number of lines read.
Failure: sets the @error flag to non_zero.
@error: 1 = Error opening specified file
2 = Empty file

Remarks

Use @extended or UBound() to determine the number of lines read.

Related

FileRead, FileReadLine

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
        ; Read the current script file into an array using the filepath.
        Local $aArray = FileReadToArray(@ScriptFullPath)
        Local $iLineCount = @extended
        If @error Then
                MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
        Else
                For $i = 0 To $iLineCount - 1 ; Loop through the array. UBound($aArray) can also be used.
                        MsgBox($MB_SYSTEMMODAL, "", $aArray[$i]) ; Display the contents of the array.
                Next
        EndIf
EndFunc   ;==>Example