Jump to content

Online txt file reader


Recommended Posts

Hello friends,
I need your help on something. The program adds the data by updating the GUI when data is added to the txt file, but when the data is deleted, the GUI does not update it, the deleted data remains.
Thanks for your help and support.

#include <File.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $aGUI = GUICreate("Standby File Check", 355, 700, -1, -1)
GUISetState(@SW_SHOW)

AdlibRegister("_Readed",1000)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _Readed()
Local $aFile, $fRow = 20, $sRow = 23, $iColum = 4
_FileReadToArray(@ScriptDir &"\"& @YEAR&@MON&@MDAY &".txt", $aFile, 0)
Local $iLines = UBound($aFile)
Local $aGUI[$iLines][$iColum]
    For $i = 0 To $iLines - 1
    $aTemp = StringSplit($aFile[$i], "|", 2)
    ReDim $aTemp[$iColum]
    $aGUI[$i][0] = GUICtrlCreateInput($aTemp[0], 20, $fRow + ($sRow * $i), 70, 20)
    $aGUI[$i][1] = GUICtrlCreateInput($aTemp[1], 95, $fRow + ($sRow * $i), 110, 20)
    $aGUI[$i][2] = GUICtrlCreateInput($aTemp[2], 210, $fRow + ($sRow * $i), 70, 20)
    $aGUI[$i][3] = GUICtrlCreateInput($aTemp[3], 285, $fRow + ($sRow * $i), 50, 20)
    Next
EndFunc

20201007.txt

0009962494|Programmer Control|07.10.2020|08:49:40
0009962494|Programmer Control|07.10.2020|08:51:18
0009962494|Programmer Control|07.10.2020|08:58:17
0009962494|Programmer Control|07.10.2020|09:01:18
0009962494|Programmer Control|07.10.2020|10:58:17
0009962494|Programmer Control|07.10.2020|11:01:18

 

Link to post
Share on other sites

Hi.

You have to either delete the input controls or to delete the text from them.

Something like this:

#include <File.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $hGUI = GUICreate("Standby File Check", 355, 700, -1, -1)
GUISetState(@SW_SHOW)

Global $sRow = 23, $iColum = 4, $iLinesmax = 2000
Global $aGUI[$iLinesmax][$iColum]

AdlibRegister("_Readed", 1000)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _Readed()
    If IsArray($aGUI) Then
        For $x = 0 To $iLinesmax - 1
            For $y = 0 To $iColum - 1
                GUICtrlDelete($aGUI[$x][$y])
            Next
        Next
    EndIf

    Local $aFile, $fRow = 20
    _FileReadToArray(@ScriptDir & "\" & @YEAR & @MON & @MDAY & ".txt", $aFile, 0)
    Local $iLines = UBound($aFile)

    For $i = 0 To $iLines - 1
        $aTemp = StringSplit($aFile[$i], "|", 2)
        ReDim $aTemp[$iColum]
        If $iLines < $iLinesmax-1 Then
            $aGUI[$i][0] = GUICtrlCreateInput($aTemp[0], 20, $fRow + ($sRow * $i), 70, 20)
            $aGUI[$i][1] = GUICtrlCreateInput($aTemp[1], 95, $fRow + ($sRow * $i), 110, 20)
            $aGUI[$i][2] = GUICtrlCreateInput($aTemp[2], 210, $fRow + ($sRow * $i), 70, 20)
            $aGUI[$i][3] = GUICtrlCreateInput($aTemp[3], 285, $fRow + ($sRow * $i), 50, 20)
        EndIf
    Next

EndFunc   ;==>_Readed

 

Edited by Dan_555
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...