Jump to content
Sign in to follow this  

Udf _filereadtoarray

Recommended Posts


Here's Larry's :whistle: UDF (hope you don't mind, Larry?)...

; Description:      Reads the specified file into an array.
; Syntax:           _FileReadToArray( $sFilePath, $aArray )
; Parameter(s):     $sFilePath - Path and filename of the file to be read
;                   $aArray    - The array to store the contents of the file
; Requirement(s):   None
; Return Value(s):  On Success - 1
;                   On Failure - 0 and sets @ERROR = 1
; Author(s):        Jonathan Bennett <jon at hiddensoft com>
; Note(s):          None
Func _FileReadToArray( $sFilePath, ByRef $aArray )
; Local Constant/Variable Declaration Section
 Local $hFile
 $hFile = FileOpen( $sFilePath, 0 )

 If $hFile = -1 Then
   SetError( 1 )
   Return 0

 $aArray = StringSplit( StringStripCR( FileRead( $hFile, _
                 FileGetSize( $sFilePath ) ) ), @LF )

 FileClose( $hFile )

 Return 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.