Writes an array to a specified file
#include <File.au3>
_FileWriteFromArray ( $sFilePath, Const ByRef $aArray [, $iBase = Default [, $iUBound = Default [, $sDelimiter = "|"]]] )
$sFilePath | Path of the file to write to, or a file handle returned by FileOpen(). |
$aArray | The array to be written to the specified file. |
$iBase | [optional] Start array index to read, normally set to 0 or 1. Default is 0. |
$iUbound | [optional] Set to the last record you want to write to the File. Default is the whole array. |
$sDelimiter | [optional] Delimiter character(s) for 2-dimension arrays. Default is "|". |
Success: | 1. |
Failure: | 0 and sets the @error flag to non-zero. |
@error: | 1 - Error opening specified file 2 - $aArray is not an array 3 - Error writing to file 4 - $aArray is not a 1D or 2D array 5 - Start index is greater than the $iUbound parameter |
If a string path is provided, the file will be overwritten and closed.
To use other write modes, like append or Unicode formats, open the file with FileOpen() first and pass the file handle instead.
If a file handle is passed, the file will still be open after writing.
#include <File.au3>
; List all the files in the current script directory.
Local $aScriptDir = _FileListToArray(@ScriptDir)
; Create a file in the users %TEMP% directory.
Local $sFilePath = @TempDir & "\Examples.txt"
; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $aScriptDir, 1)
; Display the file.
ShellExecute($sFilePath)