Jump to content

Spence

Members
  • Posts

    5
  • Joined

  • Last visited

Spence's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thank you - I hadn't thought about doing it that way! As the arrays in my scripts can be redimensioned by events, even with a locking variable I've not been able to get around these kinds of errors. But this is the perfect solution
  2. You want to use HotKeySet HotKeySet("[i]{KEY TO USE}[/i]","ExitProg") Func ExitProg() Exit() EndFunc
  3. Hi everyone, I'm fairly new with AutoIT but not to programming, I've managed to create some good scripts for my job however I've always struggled with Error Control / Handling. I've mainly made TCP event driven apps which have over 200 client connections and at times I get errors and the client just stops - ideally I'd like to handle these errors and be able to recover or in a worst case scenario, re-start the application. My issue is that whatever I try to "catch" errors, it never seems to work Here's a very simple test of error handling which, I believe should work - but doesn't: ; Error Control Test ; Wanting to handle basic errors Global $EControl = ObjEvent("AutoIt.Error", "ErrorControl") Dim $VarA Dim $VarD[1] ; Create undefined variable error $VarA = $VarB & $VarC ; Create undimensioned variable error $VarD[5] = "Testing" Func ErrorControl() ; Intercept Error Message ConsoleWriteError("Error Caught: " & $EControl.description & " (" & $EControl.number & ")" & @CRLF) return 0 EndFunc Neither "errors" are caught and just end up quitting the application. Any ideas what I'm doing wrong? Spence
  4. Hello everyone! Kip - I'm loving your application, it's great! However, I'm having issues getting the _TCP_RegisterEvent to work when called from inside a function. Why do I want to do this? I want to create a TCP Server Service - using the Service UDF. #include <TCP.au3> #include <_SQL.au3> #include <array.au3> #include <Service.au3> #include <File.au3> ... func main() $cServer = _TCP_Server_Create(88) AddToLog("Server Created on Port 88") _TCP_RegisterEvent($cServer, $TCP_NEWCLIENT, "NewClient") _TCP_RegisterEvent($cServer, $TCP_DISCONNECT, "ClientDisconnect") _TCP_RegisterEvent($cServer, $TCP_RECEIVE, "DataReceived") $Update = False AddToLog("Starting Loop") while 1 Sleep(1000) WEnd EndFunc ... The service part starts fine, clients can connect - but the three registered events do not get registered and nothing happens. Any thoughts anyone? Many thanks, Spence
  5. Hi MrBeatNik, This is quite easy to fix - in the loop put a sleep command in so that your processor isn't looping continuously: While 1 Sleep(5) WEnd This doesn't actually put a delay in your code because everything is now event driven! Kip, Great work on this! I only stumbled on AutoIT yesterday and have already been able to make good use of your TCP UDF to replace some old WSH scripts which were very long and laborious and didn't really do what I wanted! Am still trying to get my head around everything in AutoIT but I hope to get used to it very soon! Thanks again! Spence
×
×
  • Create New...