Jabberwock Posted December 14, 2005 Share Posted December 14, 2005 Hi, I was wondering if it's possible to execute a func in a loop, i have it setup to where If $msg = $connectitem Then $g_IP = InputBox("EQC Client","Enter The Server IP Address",@IPADDRESS1,"",300,200) $g_port = 33891 Sleep(500) $socket = TCPConnect( $g_IP, $g_port ) ElseIf $socket = -1 Then MsgBox(0, "Error!", "No response at " & $g_IP & " on port " & $g_port ) EndIf it just keeps spamming message boxes =/ Or mabye somthing else that could only popup the msg box once and go on? Link to comment Share on other sites More sharing options...
SlimShady Posted December 14, 2005 Share Posted December 14, 2005 hope this helps you. If $msg = $connectitem Then $g_IP = InputBox("EQC Client","Enter The Server IP Address",@IPADDRESS1,"",300,200) $g_port = 33891 Sleep(500) $socket = TCPConnect( $g_IP, $g_port ) If $socket = -1 Then MsgBox(0, "Error!", "No response at " & $g_IP & " on port " & $g_port ) Else ExitLoop EndIf EndIf Link to comment Share on other sites More sharing options...
Jabberwock Posted December 14, 2005 Author Share Posted December 14, 2005 (edited) well, this only pops up one msg box if it cannot connect but if it can connect, it exits =/ is there somhting to only apply the ExitLoop when "$socket = -1" ? Edited December 14, 2005 by Jabberwock Link to comment Share on other sites More sharing options...
SpookMeister Posted December 14, 2005 Share Posted December 14, 2005 Do you have a main loop that you aren't showing us? or is your script simply finishing after the last statement? Stick a msgbox at the bottom of your code to see for sure. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Jabberwock Posted December 14, 2005 Author Share Posted December 14, 2005 Well...i thought it was pretty self explanatory that it was running in a loop? due to my topic name? and also... $connectitem which is executed when a button is pressed Link to comment Share on other sites More sharing options...
jefhal Posted December 14, 2005 Share Posted December 14, 2005 is there somhting to only apply the ExitLoop when "$socket = -1" ?Why not: If $msg = $connectitem Then $g_IP = InputBox("EQC Client","Enter The Server IP Address",@IPADDRESS1,"",300,200) $g_port = 33891 Sleep(500) $socket = TCPConnect( $g_IP, $g_port ) If $socket = -1 Then MsgBox(0, "Error!", "No response at " & $g_IP & " on port " & $g_port ) ExitLoop Else tooltip("Whoopeee!") EndIf EndIf ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Jabberwock Posted December 14, 2005 Author Share Posted December 14, 2005 That dosn't work, it's basically the same thing the other person suggested, it just pops up the msgbox then exits Link to comment Share on other sites More sharing options...
jefhal Posted December 15, 2005 Share Posted December 15, 2005 That dosn't work, it's basically the same thing the other person suggested, it just pops up the msgbox then exitsNo, it only exits the loop IF $socket = -1The other one exits the loop IF $socket <> -1Big difference. Maybe you could explain what you really want? ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Jabberwock Posted December 15, 2005 Author Share Posted December 15, 2005 pretty much i want it to let the end user know if there's a problem connecting, pop up a msg box, and mabye give the user another chance to connect, with this code and no server online it will popup the msg box then exit, If $msg = $connectitem Then $g_IP = InputBox("EQC Client","Enter The Server IP Address",@IPADDRESS1,"",300,200) $g_port = 33891 Sleep(500) $socket = TCPConnect( $g_IP, $g_port ) If $socket = -1 Then MsgBox(0, "Error!", "No response at " & $g_IP & " on port " & $g_port ) ExitLoop Else ;tooltip("Whoopeee!"); don't really need this tried it with anyway, just pops up forever if there's an actual server EndIf EndIf the $connectitem is part of a menu $connectitem = GuiCtrlCreateMenuitem ("Connect",$filemenu)and If $msg = $connectitem Then is in a While 1 $msg = GUIGetMsg()loop Link to comment Share on other sites More sharing options...
jefhal Posted December 15, 2005 Share Posted December 15, 2005 Without your complete code it's way too much work to troubleshoot your code, but here's my last effort: If $msg = $connectitem Then $g_IP = InputBox("EQC Client","Enter The Server IP Address",@IPADDRESS1,"",300,200) $g_port = 33891 Sleep(500) $socket = TCPConnect( $g_IP, $g_port ) If $socket = -1 Then MsgBox(0, "Error!", "No response at " & $g_IP & " on port " & $g_port,3 ); goes away after 3 seconds Else tooltip("Whoopeee") sleep(3000) ; tooltip goes away after 3 seconds tooltip("") EndIf EndIf ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Jabberwock Posted December 15, 2005 Author Share Posted December 15, 2005 i changed a few things around, and when i added this code it worked, i'm not sure why it works now, i even tested it without the tooltip and without the msg box disappearing after 3 seconds, but thanks. 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