Func _CopySbLog()
;after all loop copy file Sb.txt to Sb_logs directory with name + "Data+Time" + Serial
$PathSbLog = "c:\tester\Sb_Win10\Sb.txt"
$PathToCopyLogs = "c:\tester\logs\Sb_Logs\"
$PathCSV = "c:\tester\logs\CSV\CSV.txt"
$Ser = GUICtrlRead($SerialN)
FileCopy($PathSbLog, $PathToCopyLogs & "Sb-" & @YEAR & '-' & @MON & '-' & @MDAY & '-' & @HOUR & '-' & @MIN & '-' & @SEC & '-' & $Ser & ".txt")
Sleep(1000)
;insert Sb.txt to multi array
#Region add to array
$i = 1 ; lines of file. start from line 2
$z = 0 ;line of array
$j = -1 ;row of array
Dim $aParsing[100][8]
Global $hFile = FileOpen($PathSbLog)
If $hFile = -1 Then
MsgBox(4096, "Error", "Not found file:" & $PathSbLog)
Exit
EndIf
$TestTime = FileReadLine($hFile, 1)
$TT = StringSplit($TestTime, ','' ')
Global $TT2 = $TT[4]
Global $TT3 = $TT[6]
While 1
$i += 1
$sTemp = FileReadLine($hFile, $i)
If @error = -1 Then ExitLoop
$z += 1
If StringInStr($sTemp, "ric#") Then
$j += 1
$z = 0
EndIf
$aParsing[$z][$j] = $sTemp
WEnd
FileFlush($PathSbLog)
FileClose($PathSbLog)
Sleep(1000)
#EndRegion add to array
#Region parsing
Global $Mas[0], $AllMas[50][8]
$r = 0
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
$r = 1
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
$r = 2
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
$r = 3
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
$r = 4
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
$r = 5
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
$r = 6
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
$r = 7
Local $aNumbers = StringSplit($aParsing[0][$r], ', ''.''=')
$Mas = $aNumbers
For $i = 0 To $Mas[0] - 1
$AllMas[$i][$r] = $Mas[$i + 1]
Next
Local $aNumbers = StringSplit($aParsing[1][$r], ' = ''°')
$Mas2 = $aNumbers
For $i = 0 To $Mas2[0] - 1
$AllMas[$i + 7][$r] = $Mas2[$i + 1]
Next
#EndRegion parsing
;insert data to GUI.
For $i = 0 To 3
GUICtrlSetData($array[0][$i + 1], $AllMas[18][$i])
GUICtrlSetData($array[1][$i + 1], $AllMas[2][$i])
GUICtrlSetData($array[2][$i + 1], $AllMas[6][$i])
GUICtrlSetData($array[3][$i + 1], $AllMas[11][$i])
Next
;insert data to CSV
Local $hCSV = FileOpen($PathCSV, 1)
; check file is open/possible to edit
If $hCSV = -1 Then
MsgBox(4096, "Error", "Not found file:" & $PathCSV)
Exit
EndIf
; write to CSV.
FileWrite($hCSV, $TT2 & "," & $TT3 & "," & $AllMas[2][0] & "," & $AllMas[6][0] & "," & $AllMas[11][0] & "," & $AllMas[18][0] & "," & _
$AllMas[2][1] & "," & $AllMas[6][1] & "," & $AllMas[11][1] & "," & $AllMas[18][1] & "," & _
$AllMas[2][2] & "," & $AllMas[6][2] & "," & $AllMas[11][2] & "," & $AllMas[18][2] & "," & _
$AllMas[2][3] & "," & $AllMas[6][3] & "," & $AllMas[11][3] & "," & $AllMas[18][3] & "," & _
$AllMas[2][4] & "," & $AllMas[6][4] & "," & $AllMas[11][4] & "," & $AllMas[18][4] & "," & _
$AllMas[2][5] & "," & $AllMas[6][5] & "," & $AllMas[11][5] & "," & $AllMas[18][5] & "," & _
$AllMas[2][6] & "," & $AllMas[6][6] & "," & $AllMas[11][6] & "," & $AllMas[18][6] & "," & _
$AllMas[2][7] & "," & $AllMas[6][7] & "," & $AllMas[11][7] & "," & $AllMas[18][7] & "," & @CRLF)
Sleep(1000)
FileFlush($PathCSV)
FileClose($PathCSV)
EndFunc ;==>_CopySbLog