-
AutoIt
(
http://forum.oszone.net/forumdisplay.php?f=103)
Некоректно отрабатывает функция создания ListView из файла-источника
Суть проблемы:
Есть код:
Код:
Func Getdata()
$File = FileOpen($Filename,0)
If $file = -1 Then ;Check if file is opened for reading, OK
MsgBox(0, "Error", "Unable to open file. Make sure that your Firewall Logging is turned on !!")
Exit
EndIf
$Combo1Item=Number(GUICtrlRead($Tab1combo1)) ;Get # of lines selected
$aArray = StringSplit(FileRead($file,FileGetSize($filename)),@LF) ;Read lines of text until the EOF is reached
for $i = (UBound($aArray) - 2) to $i+1-$combo1Item Step -1 ;Ubound read lines bottom up, to # of lines
$string = StringSplit($aArray[$i], " ", 0) ;Split lines in 17 dimensions
For $a=0 To 13 ;Assign each 13 dimensions to a new Array
$avArray[$a]=$string[$a]
next ;Create string for displaying in ListView
$data=$avArray[1]&"|"&$avArray[2]&"|"&$avArray[3]&"|"&$avArray[4]&"|"&$avArray[5]&"|" _
&$avArray[6]&"|"&$avArray[7]&"|"&$avArray[8]&"|"&$avArray[9]&"|"&$avArray[10]&"|"&$avArray[11]&"|"&$avArray[12]&"|"&$avArray[13]
$dataCol=GUICtrlCreateListViewItem($data,$listview)
Next
FileClose($file)
EndFunc
Проблема:
при открытии файла (лог файрволла) в случае выбора в комбобооксе количества строк больше, чем в файлее-источнике функция вываливается с ошибкой. Помогите разобраться.
Ошибка происходит в месте
Код:
For $a=0 To 13 ;Assign each 13 dimensions to a new Array
$avArray[$a]=$string[$a]
next
|
решение получено от madmasles ( http://autoit-script.ru/index.php/topic,2809.0.html)
на всякий, выкладываю рабочий код:
Код:
Func Getdata()
$file = FileOpen($Filename,0)
If $file = -1 Then ;Check if file is opened for reading, OK
MsgBox(0, "Ошибка", "Невозможно открыть файл логов. Проверьте, включено ли логирование, или путь к файлу логов!!!")
Else
$Combo1Item=Number(GUICtrlRead($Tab1combo1)) ;Get # of lines selected
$aArray = StringSplit(FileRead($file,FileGetSize($filename)),@LF)
If $aArray[0] < $Combo1Item Then
$Combo1Item = $aArray[0]
EndIf
for $i = (UBound($aArray) - 2) to $i+7-$combo1Item Step -1 ;Ubound read lines bottom up, to # of lines
$string = StringSplit($aArray[$i], " ", 0) ;Split lines in 17 dimensions
For $a=0 To 13 ;Assign each 13 dimensions to a new Array
$afArray[$a] = $string[$a]
next ;Create string for displaying in ListView
$data=$afArray[1]&"|"&$afArray[2]&"|"&$afArray[3]&"|"&$afArray[4]&"|"&$afArray[5]&"|" _
&$afArray[6]&"|"&$afArray[7]&"|"&$afArray[8]&"|"&$afArray[9]&"|"&$afArray[10]&"|"&$afArray[11]&"|"&$afArray[12]&"|"&$afArray[13]
$dataCol=GUICtrlCreateListViewItem($data,$listviewFw)
Next
FileClose($file)
EndIf
EndFunc
|
Время: 19:56.
© OSzone.net 2001-