Warmonger Posted April 8, 2011 Share 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] Link to comment Share on other sites More sharing options...
AutoBert Posted April 8, 2011 Share 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 Link to comment Share on other sites More sharing options...
Warmonger Posted April 8, 2011 Author Share 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] Link to comment Share on other sites More sharing options...
hannes08 Posted April 8, 2011 Share 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] Link to comment Share on other sites More sharing options...
Warmonger Posted April 8, 2011 Author Share 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] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now