Created this as I had a specific need.
Please comment, and should this be an UDF after all comments are done?
Code:
;FUNCTION Convert2array
;
;ACTION Take a plain text file and convert it into an array
; that allows for use of includes
;
;AUTHOR Gargoyle
;
;CONTRIBUTORS Many for the suggestions on how to create this
; so that you can then tokenize the data and still
; "include".
;
;VERSION 1.0.1
;
;DATE CREATED 12.23.05
;
;DATE MODIFIED 12.23.05
;
;KIXTART Only tested with 4.51
;
;SYNTAX Convert2array(FileToConvert,FileToSave,ArrayName)
;
;PARAMETERS
; File to Convert
; Name of the input file, if not in the scriptdirectory
; specify full path name
;
; File to Save
; Name of the output file, if you don't want it in the
; script directory specify the full path.
;
; Array Name
; What name to you want to assign to the created array elements
;
;RETURNS Nothing
;
;REMARKS
;
;DEPENDENCIES
;
;KIXTART BBS
;
;
Function Convert2Array($IN,$Out,$Name)
SetOption ("NoVarsInStrings", ON)
Dim $Read, $Count, $FH, $In, $Out, $Name, $Array[]
$FH = FreeFileHandle()
$Count = 0
If Open($FH,$IN,2) = 0
$Read = ReadLine($FH)
While @ERROR = 0
ReDim Preserve $Array[$Count]
$Array[$Count] = $Read
$Count = $Count + 1
$Read = ReadLine($FH)
Loop
Close($FH)
Else
$ = MessageBox("Error opening File" + @CRLF + @SERROR,"Warning",16)
Exit @Error
EndIf
If Open($FH,$OUt,5) = 0
For $ = 0 to Ubound($Array)
WriteLine($FH,"$"+$Name+"["+$+"] = '" + $Array[$] + "'"+@CRLF)
Next
Close($FH)
Else
$ = MessageBox("Error opening File" + @CRLF + @SERROR,"Warning",16)
EndIf
EndFunction