Warmonger 0 Posted April 8, 2011 (edited) How would I go about updating a array or variable. While script is running. And how would I go about updating a array/variable on a loop. Possible with AdlibRegister? Would putting them inside a function and calling that function every so often work? What im trying to constantly update. Global $BanIP Global $Admin Global $NameBan _FileReadToArray('Ban.txt', $BanIP) _FileReadToArray('Admin.txt', $Admin) _FileReadToArray('Name.txt', $NameBan) Edited April 8, 2011 by Warmonger [AutoIt File Patcher] Share this post Link to post Share on other sites
AutoBert 197 Posted April 8, 2011 Hello, just test this script:expandcollapse popup#Include <File.au3> Global $BanIP Global $Admin Global $NameBan Global $aUpdate[3][2] Global $aInfo[3] $aUpdate[0][0] = @ScriptDir & '\Ban.txt' $aUpdate[1][0] = @ScriptDir & '\Admin.txt' $aUpdate[2][0] = @ScriptDir & '\Name.txt' #include <GUIConstants.au3> #region - GUI Create GUICreate('Test',800,200) for $i = 0 to 2 $aInfo[$i] = GUICtrlCreateLabel("",10,10+$i*40,750,25) Next GUISetState() #endregion AdlibRegister("_CheckChanges", 2000) #region - GUI SelectLoop Do until GUIGetMsg() = -3 #endregion Func _CheckChanges() For $i = 0 To 2 $dtFile = FileGetTime($aUpdate[$i][0],0,1) If $dtFile <> $aUpdate[$i][1] Then ConsoleWrite($i & ": Changed " & $dtFile & @CRLF) $aUpdate[$i][1] = $dtFile Switch $i Case 0 _FileReadToArray($aUpdate[$i][0], $BanIP) Case 1 _FileReadToArray($aUpdate[$i][0], $Admin) Case 2 _FileReadToArray($aUpdate[$i][0], $NameBan) EndSwitch GUICtrlSetData($aInfo[$i],$aUpdate[$i][0] & ": Last Changed " & $dtFile) EndIf Next EndFunc mfg autoBert Share this post Link to post Share on other sites
Warmonger 0 Posted April 8, 2011 Hello, just test this script:expandcollapse popup#Include <File.au3> Global $BanIP Global $Admin Global $NameBan Global $aUpdate[3][2] Global $aInfo[3] $aUpdate[0][0] = @ScriptDir & '\Ban.txt' $aUpdate[1][0] = @ScriptDir & '\Admin.txt' $aUpdate[2][0] = @ScriptDir & '\Name.txt' #include <GUIConstants.au3> #region - GUI Create GUICreate('Test',800,200) for $i = 0 to 2 $aInfo[$i] = GUICtrlCreateLabel("",10,10+$i*40,750,25) Next GUISetState() #endregion AdlibRegister("_CheckChanges", 2000) #region - GUI SelectLoop Do until GUIGetMsg() = -3 #endregion Func _CheckChanges() For $i = 0 To 2 $dtFile = FileGetTime($aUpdate[$i][0],0,1) If $dtFile <> $aUpdate[$i][1] Then ConsoleWrite($i & ": Changed " & $dtFile & @CRLF) $aUpdate[$i][1] = $dtFile Switch $i Case 0 _FileReadToArray($aUpdate[$i][0], $BanIP) Case 1 _FileReadToArray($aUpdate[$i][0], $Admin) Case 2 _FileReadToArray($aUpdate[$i][0], $NameBan) EndSwitch GUICtrlSetData($aInfo[$i],$aUpdate[$i][0] & ": Last Changed " & $dtFile) EndIf Next EndFunc mfg autoBert Im inside a console so everything's event driven. Im looking to update the data the array holds not checking for the last update taken to file. The file holds the data for the array. I want the array to automatically update as I add more data in the file. [AutoIt File Patcher] Share this post Link to post Share on other sites
hannes08 39 Posted April 8, 2011 Hi warmonger, that's what autobert has written, it checks whether the file has been updated, an if it's updated, the array will be updated. You cannot read changes from a file that has not been saved yet. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Share this post Link to post Share on other sites
Warmonger 0 Posted April 8, 2011 Calling them every so often will update them like I stated before. #include <File.au3> #include <Console.au3> Cout('Testing Active Array Updates') Cout(@CRLF) Global $BanIP Global $Admin Global $NameBan AdlibRegister('_UpdateArray', 5000) While 1 = 1 Sleep(10) WEnd Func _UpdateArray() _FileReadToArray('Ban.txt', $BanIP) _FileReadToArray('Admin.txt', $Admin) _FileReadToArray('Name.txt', $NameBan) Cout('Ban ' & $BanIP[0]) Cout(@CRLF) Cout('Admin ' & $Admin[0]) Cout(@CRLF) Cout('Name ' & $NameBan[0]) Cout(@CRLF) EndFunc [AutoIt File Patcher] Share this post Link to post Share on other sites