Kyler Carlson Posted October 6, 2006 Share Posted October 6, 2006 okay. I'm making a chatting program for my network. Right now, I'm using ini's to save the chat log to the network and to read the chat log. It is currently set up to check the ini file every 1/2 a second but it ramdomly will get very laggy and can take up to 15 seconds to display a message. I really don't know why this is happening. Any help about fixing that or any other bugs you see are appreciated. expandcollapse popup#include <GUIConstants.au3> #Include <Date.au3> #NoTrayIcon HotKeySet("^i","special") ;IniWrite("c:\walls\location.ini","location","location","") $location = IniRead(@ScriptDir & "\location.ini","location","location",@ScriptDir);"c:" $name = "\chat.ini" $msg2 = "" $bg = "" $exit = "" $refresh = "" $set = "" $active = "" $effect = "" $name2 = "" ;If IsAdmin() Then Exit GUICreate("Talk Alpha",800,600,0,0) $start = GUICtrlCreateButton("Start Chat",20,20,75,30) $channel = GUICtrlCreateInput("Channel",115,25,75,20) $input = GUICtrlCreateInput("",20,100,760,430,"0x00201004") $msg3 = GUICtrlCreateInput("",20,550,670,20) $send = GUICtrlCreateButton("Send",710,545,50,30) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE and WinActive("Talk Alpha") then exit1() If $msg = $start Then start() If $msg = $exit Then WinClose("Specialness...") If $msg = $refresh Then $list = IniRead($location & $name,"Names","Users","") $list = StringReplace($list,"¡",@crlf) GUICtrlSetData($active,$list) EndIf If $msg = $set Then change() sleep(100) WEnd Func start() $count = 0 $channel = GUICtrlRead($channel) $users = IniRead($location & $name,"Names","Users","") $chans = IniRead($location & $name,"Names","Users and Channels","") IniWrite($location & $name,"Names","Users", @UserName & "¡" & $users) IniWrite($location & $name,"Names","Users and Channels", @UserName & ": " & $channel& "¡" & $chans) HotKeySet("{enter}","enter") While 1 $count = $count + 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE and WinActive("Talk Alpha") then exit1() If $count = 10 Then $talk = IniRead($location & $name,"Chat",$channel,"") $talk1 = StringReplace($talk,"¡",@CRLF) GUICtrlSetData(5,$talk1,"") $count = 0 changewall() EndIf If $msg = $send Then sendmsg() If $msg = $exit Then WinClose("Specialness...") If $msg = $refresh Then $list = IniRead($location & $name,"Names","Users","") $list = StringReplace($list,"¡",@crlf) GUICtrlSetData($active,$list) EndIf If $msg = $set Then change() sleep(50) WEnd EndFunc Func exit1() $users = IniRead($location & $name,"Names","Users","") $chans = IniRead($location & $name,"Names","Users and Channels","") $users = StringReplace($users,@UserName & "¡","") $chans = StringReplace($chans,@UserName & ": " & $channel& "¡","") IniWrite($location & $name,"Names","Users", $users) IniWrite($location & $name,"Names","Users and Channels", $chans) If $users = "" Or $chans = "" Then IniDelete($location & $name,"Chat",$channel) Exit EndFunc Func enter() If WinActive("Talk Alpha") Then sendmsg() Else HotKeySet("{enter}") Send("{enter}") HotKeySet("{enter}","enter") EndIf EndFunc Func sendmsg() $msg2 = GUICtrlRead($msg3) $msg_old = IniRead($location & $name,"Chat",$channel,"") IniWrite($location & $name,"Chat",$channel, @UserName & ": " & _NowTime(5) & " -- " & $msg2 & "¡" & $msg_old) GUICtrlSetData($msg3,"") EndFunc that is a shortened version of my code. I'll paste the full version if anyone things its needed but I'm not having issues with that part. Link to comment Share on other sites More sharing options...
Valuater Posted October 6, 2006 Share Posted October 6, 2006 (edited) you can remove this... sleep(50) because you have $msg = GUIGetMsg() in the while loop 8) BTW Sleep(500) is 1/2 second Edited October 6, 2006 by Valuater Link to comment Share on other sites More sharing options...
Kyler Carlson Posted October 6, 2006 Author Share Posted October 6, 2006 okay but still odd things... Func start() $whileile = 0 $count = 0 $channel = GUICtrlRead($channel) $users = IniRead($location & $name,"Names","Users","") $chans = IniRead($location & $name,"Names","Users and Channels","") IniWrite($location & $name,"Names","Users", @UserName & "¡" & $users) IniWrite($location & $name,"Names","Users and Channels", @UserName & ": " & $channel& "¡" & $chans) HotKeySet("{enter}","enter") While 1 $count = $count + 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE and WinActive("Talk Alpha") then exit1() ;If $count = 2 Then MsgBox(0,"","") $talk = IniRead($location & $name,"Chat",$channel,"") $talk1 = StringReplace($talk,"¡",@CRLF) GUICtrlSetData(5,$talk1,"") $count = 0 changewall() ;EndIf If $msg = $send Then sendmsg() If $msg = $exit Then WinClose("Specialness...") If $msg = $refresh Then $list = IniRead($location & $name,"Names","Users","") $list = StringReplace($list,"¡",@crlf) GUICtrlSetData($active,$list) EndIf If $msg = $set Then change() ;sleep(50) WEnd EndFunc for some odd reason... the message boxes aren't poping up steadily. It will pop up somewhere between 4-10 times in very quick sucession (basically instantly) but then... it randomly takes a break of 3-15 seconds... i have no idea why. does anyone?? Link to comment Share on other sites More sharing options...
cppman Posted October 6, 2006 Share Posted October 6, 2006 (edited) use AdLibEnable()... like this: AdLibEnable("ReadINI", 500) ;calls ReadINI() every 1/2 second. While 1 sleep(100) Wend Func ReadINI() ;Do your stuff here EndFunc I cant really test it out, because alot of functions are missing.. Edited October 6, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Kyler Carlson Posted October 6, 2006 Author Share Posted October 6, 2006 (edited) the AdLibEnable seems to be fixing everything. thanks a whole lot to all who helped. Edid: spelling Edited October 6, 2006 by Kyler Carlson 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