DarkBoost Posted June 2, 2010 Share Posted June 2, 2010 I am using _FileReadToArray() to read a TXT file in a loop and then send the array results to a GUICtrlCreateEdit(). It is in a loop because the TXT file will continue to be updated and I need the GUICtrlCreateEdit() to display these results. Could someone please explain why the array is not updating after the TXT has been updated. Also is there possibly a better way to achieve this? ;EXAMPLE ONLY======================================== Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <File.au3> GUICreate("", 500, 500) Dim $edit = GUICtrlCreateEdit("", 10, 10, 480, 480) Dim $array GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") GUISetState() While 1 _FileReadToArray(@ScriptDir & "\file.txt", $array) If Not @error Then GUICtrlSetData($edit, "") ;clear edit field to avoid duplicates For $x = 1 To $array[0] GUICtrlSetData($edit, $array[$x] & @CRLF, 1) Next EndIf $array = "" ;clear array Sleep(5000) ;sleep for 5 seconds WEnd Func _exit() Exit EndFunc Link to comment Share on other sites More sharing options...
UEZ Posted June 2, 2010 Share Posted June 2, 2010 (edited) Maybe the file file.txt is locked by another process when it is been updated?How long is your file.txt?Try this:;EXAMPLE ONLY======================================== Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <File.au3> GUICreate("", 500, 500) $edit = GUICtrlCreateEdit("", 10, 10, 480, 480) GUICtrlSetLimit(-1, 0x7FFFFFFF) Dim $array GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") GUISetState() While 1 _FileReadToArray(@ScriptDir & "\file.txt", $array) If Not @error Then ConsoleWrite($array[0] & @CRLF & @CRLF) GUICtrlSetData($edit, "") ;clear edit field to avoid duplicates For $x = 1 To $array[0] GUICtrlSetData($edit, $array[$x] & @CRLF, 1) Next EndIf $array = 0 ;clear array Sleep(5000) ;sleep for 5 seconds WEnd Func _exit() Exit EndFuncBR,UEZ Edited June 2, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
DarkBoost Posted June 2, 2010 Author Share Posted June 2, 2010 i found that the issue was i was not closing the file correctly in another function *doh*. slightly off topic, can you set a specific color to a word in an edit box? Link to comment Share on other sites More sharing options...
Yoriz Posted June 2, 2010 Share Posted June 2, 2010 To set specific colours in an edit, you can use a richedit rather then a normal edit and then use _GUICtrlRichEdit_SetCharColor, see the example in the helpfile. GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. 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