$file is filename... returns an array of each line in $file
code:
Function ReadFile($file)
Dim $lf, $f
$lf=chr(10)
$f=freefilehandle
$=open($f,$file)
if @error exit @error endif
do $t=$t+$lf+readline($f) until @error
$=close($f)
$ReadFile=split(substr($t,2),$lf)
EndFunction
$file is filename
$array is array of text to be written to file. CRLF will be automatically appended to each line
code:
Function WriteFile($file,$array)
Dim $f, $line
If Not VarType($Array) & 8192 Exit(1) EndIf
$f=freefilehandle
$=open($f,$file,5)
if @error exit @error endif
for each $line in $array
$=writeline($f,$line+@crlf)
if @error exit @error endif
endif
$=close($f)
EndFunction
$array is array of text
$find is string of text to match
$inclusive is whether to return lines with the string or without the string
code:
Function FilterArray($array,$find, optional $inclusive)
Dim $lf, $t, $l, $sp
$lf=chr(10) $sp=chr(32)
If Not VarType($Array) & 8192 Exit(1) EndIf
for each $l in $array
if (instr($l,$find) and $inclusive and trim($l)> $sp)
or (not instr($l,$find) and not $inclusive and trim($l)> $sp)
$t=$t+$lf+$l
endif
next
$FilterArray=split(substr($t,2),$lf)
EndFunction
[ 12. October 2003, 15:48: Message edited by: Radimus ]