Jump to content

Possible to execute a func in a loop?


Jabberwock
 Share

Recommended Posts

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

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

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

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

That dosn't work, it's basically the same thing the other person suggested, it just pops up the msgbox then exits

No, it only exits the loop IF $socket = -1

The other one exits the loop IF $socket <> -1

Big 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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...