Jump to content
Sign in to follow this  
Drew

Error: And I can't get why...

Recommended Posts

Drew

The code should not essentially be working yet, its just a base code that is unfinished but it is getting the error and we cannot figure out why its coming up.

Here's the script:

#Include <Array.au3>
;~ HotKeySet('!c', '_Test'); Set up an A hotkey to send the message
HotKeySet('!n', '_MsgBox')

Dim $iMainSocket = 0
Dim $iConnectedSocket = -1
Dim $sData = ""
global $array[1000]=[0]
$array[0]=0
TCPStartup()
$iMainSocket = TCPListen(@IPAddress1,7000)
;$array[$array[0]] = $iConnectedSocket
    
While 1
    for $i=1 to $array[0]
        If $iConnectedSocket >= 0 Then
            $IP = TCPRecv($iConnectedSocket, 1024)
            If @error Then
                $array[$i] = -1
                If $array[$i] >= 0 Then  $sData = TCPRecv($array[$i],1024)  
                    $IP = TCPRecv($array[$i], 1024)  
                    If @error Then  
                        $array[$i] = "disconnected"
                        ConsoleWrite("Client has disconnected" & @CRLF)
                    endif
                ElseIf $IP Then
                    IniWrite(@DesktopDir&"\Logs\IP.ini", $IP, $iConnectedSocket, "Array")
                EndIf  
            endif
        Else
            $array[0]=$array[0]+1
            $array[$i] = TCPAccept($iMainSocket)
            If $array[$i] >= 0 Then
                TcpSend($array[$i], "$sIP")
                if not @error then
                    ConsoleWrite("Connection established" & @CRLF)
                Else
                    $array[$i]="disconnected"
                EndIf
            EndIf
        EndIf
    next
Wend

Func _MsgBox()
     TcpSend($iConnectedSocket, "$sIP")
EndFunc

We're both tired , but regardless we can't see whats wrong with the code. If someone with a fresh mind could look it over I would be grateful.

Regards,

Share this post


Link to post
Share on other sites
BrettF

The code should not essentially be working yet, its just a base code that is unfinished but it is getting the error and we cannot figure out why its coming up.

Here's the script:

#Include <Array.au3>
;~ HotKeySet('!c', '_Test'); Set up an A hotkey to send the message
HotKeySet('!n', '_MsgBox')

Dim $iMainSocket = 0
Dim $iConnectedSocket = -1
Dim $sData = ""
global $array[1000]=[0]
$array[0]=0
TCPStartup()
$iMainSocket = TCPListen(@IPAddress1,7000)
;$array[$array[0]] = $iConnectedSocket
    
While 1
    for $i=1 to $array[0]
        If $iConnectedSocket >= 0 Then
            $IP = TCPRecv($iConnectedSocket, 1024)
            If @error Then
                $array[$i] = -1
                If $array[$i] >= 0 Then  $sData = TCPRecv($array[$i],1024)  
                    $IP = TCPRecv($array[$i], 1024)  
                    If @error Then  
                        $array[$i] = "disconnected"
                        ConsoleWrite("Client has disconnected" & @CRLF)
                    endif
                ElseIf $IP Then
                    IniWrite(@DesktopDir&"\Logs\IP.ini", $IP, $iConnectedSocket, "Array")
                EndIf  
            endif
        Else
            $array[0]=$array[0]+1
            $array[$i] = TCPAccept($iMainSocket)
            If $array[$i] >= 0 Then
                TcpSend($array[$i], "$sIP")
                if not @error then
                    ConsoleWrite("Connection established" & @CRLF)
                Else
                    $array[$i]="disconnected"
                EndIf
            EndIf
        EndIf
    next
Wend

Func _MsgBox()
     TcpSend($iConnectedSocket, "$sIP")
EndFunc

We're both tired , but regardless we can't see whats wrong with the code. If someone with a fresh mind could look it over I would be grateful.

Regards,

What type of error is it? Is it in SciTe? Does a msg box pop up when the script runs? WTF is the error?

Share this post


Link to post
Share on other sites
Drew

Lol That would help huh... Sorry , as I said. I'm pretty tired.

[.......]\Server_Side.au3 (30) : ==> "Else" statement with no matching "If" statement.:

Else

Share this post


Link to post
Share on other sites
Drew

Now I'm getting this one. ( No change to the script has been made. )

[.....]\Server_Side.au3(30,3) : ERROR: missing Next.

EDIT

Full list of errors:

>C:\Program Files\AutoIt3\SciTE\..\au3check.exe "C:\Documents and Settings\Administrator\Desktop\Dreu's Server-Side Prog Work\Server_Side.au3"

AutoIt3 Syntax Checker v1.54.8 Copyright © Tylo 2007

C:\Documents and Settings\Administrator\Desktop\Dreu's Server-Side Prog Work\Server_Side.au3(30,3) : ERROR: missing Next.

Else

^

C:\Documents and Settings\Administrator\Desktop\Dreu's Server-Side Prog Work\Server_Side.au3(15,14) : REF: missing Next.

For $i=1 to

~~~~~~~~~~~~~^

C:\Documents and Settings\Administrator\Desktop\Dreu's Server-Side Prog Work\Server_Side.au3(30,3) : ERROR: missing Wend.

Else

^

C:\Documents and Settings\Administrator\Desktop\Dreu's Server-Side Prog Work\Server_Side.au3(14,1) : REF: missing Wend.

While

^

C:\Documents and Settings\Administrator\Desktop\Dreu's Server-Side Prog Work\Server_Side.au3(30,3) : ERROR: syntax error

Else

^

C:\Documents and Settings\Administrator\Desktop\Dreu's Server-Side Prog Work\Server_Side.au3(3,26) : ERROR: _MsgBox(): undefined function.

HotKeySet('!n', '_MsgBox')

~~~~~~~~~~~~~~~~~~~~~~~~~^

Edited by Drew

Share this post


Link to post
Share on other sites
therks

I believe this section of code is mucking up on you.

If $array[$i] >= 0 Then  $sData = TCPRecv($array[$i],1024)  
    $IP = TCPRecv($array[$i], 1024)  
    If @error Then  
        $array[$i] = "disconnected"
        ConsoleWrite("Client has disconnected" & @CRLF)
    endif
ElseIf $IP Then
    IniWrite(@DesktopDir&"\Logs\IP.ini", $IP, $iConnectedSocket, "Array")
EndIf

You can't have If..Else if you put anything after the Then on the same line. Just separate that first line into two.

Share this post


Link to post
Share on other sites
MerkurAlex

I believe this section of code is mucking up on you.

If $array[$i] >= 0 Then  $sData = TCPRecv($array[$i],1024)  
    $IP = TCPRecv($array[$i], 1024)  
    If @error Then  
        $array[$i] = "disconnected"
        ConsoleWrite("Client has disconnected" & @CRLF)
    endif
ElseIf $IP Then
    IniWrite(@DesktopDir&"\Logs\IP.ini", $IP, $iConnectedSocket, "Array")
EndIf

You can't have If..Else if you put anything after the Then on the same line. Just separate that first line into two.

That is not the problem with our code...

All of the else's and elseif's have matching if's there shouldn't be a problem..

Edited by MerkurAlex

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
Jos

Run tidy which gives:

#Tidy_Parameters=/rel 1
#include <Array.au3>
;~ HotKeySet('!c', '_Test'); Set up an A hotkey to send the message
HotKeySet('!n', '_MsgBox')
Dim $iMainSocket = 0
Dim $iConnectedSocket = -1
Dim $sData = ""
Global $array[1000] = [0]
$array[0] = 0
TCPStartup()
$iMainSocket = TCPListen(@IPAddress1, 7000)
;$array[$array[0]] = $iConnectedSocket
While 1
    For $i = 1 To $array[0]
        If $iConnectedSocket >= 0 Then
            $IP = TCPRecv($iConnectedSocket, 1024)
            If @error Then
                $array[$i] = -1
                If $array[$i] >= 0 Then $sData = TCPRecv($array[$i], 1024)
                $IP = TCPRecv($array[$i], 1024)
                If @error Then
                    $array[$i] = "disconnected"
                    ConsoleWrite("Client has disconnected" & @CRLF)
                EndIf
            ElseIf $IP Then
                IniWrite(@DesktopDir & "\Logs\IP.ini", $IP, $iConnectedSocket, "Array")
            EndIf
        EndIf
;### Tidy Error -> "else" is closing previous "for"
    Else
        $array[0] = $array[0] + 1
        $array[$i] = TCPAccept($iMainSocket)
        If $array[$i] >= 0 Then
            TCPSend($array[$i], "$sIP")
            If Not @error Then
                ConsoleWrite("Connection established" & @CRLF)
            Else
                $array[$i] = "disconnected"
            EndIf
        EndIf
;### Tidy Error -> "endif" is closing previous "for"
    EndIf
;### Tidy Error -> "next" is closing previous "while"
Next
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
WEnd
Func _MsgBox()
    TCPSend($iConnectedSocket, "$sIP")
EndFunc  ;==>_MsgBox

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
James

Drew, you don't need to keep making topics, just have one which will hold all of your problems. Much easier and that way it's easier to see what help you have had and what has changed in your code :)

Share this post


Link to post
Share on other sites
Drew

Same errors.

Share this post


Link to post
Share on other sites
MerkurAlex

What same error ?

Did you change anything ?

No he tried that Tidy code or something we were unable to find out what was wrong so i rewrote the code for him...

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
Jos

No he tried that Tidy code or something we were unable to find out what was wrong so i rewrote the code for him...

I think when posts are made that pinpoint what the problem is in the script, the OP could at least put in a bit of effort to try to understand and do something with it in stead of posting as he did in his last post.

my 2 cents :)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Drew

I did try , alot. But it's very difficult trying to correct a problem when you can't find the problem. I looked over that script countless countless times and could never find anything to correct. Do you see anything wrong with it that would produce errors?

...me either.

But I also tried the Tidy thing you suggested. I was just letting you know that didn't work either.

Regardless , thank you for replying.

Edited by Drew

Share this post


Link to post
Share on other sites
MerkurAlex

I think when posts are made that pinpoint what the problem is in the script, the OP could at least put in a bit of effort to try to understand and do something with it in stead of posting as he did in his last post.

my 2 cents :)

I have been talking to him on MSN alot and helping him he is trying to understand alot and is for that matter im just helping him along and i rewrote this cause i needed it also he did not ask me to rewrite it for him at all im just helping a friend and myself at the same time....

my 2 cents :(

Edited by MerkurAlex

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
SmOke_N

I did try , alot. But it's very difficult trying to correct a problem when you can't find the problem. I looked over that script countless countless times and could never find anything to correct. Do you see anything wrong with it that would produce errors?

...me either.

But I also tried the Tidy thing you suggested. I was just letting you know that didn't work either.

Regardless , thank you for replying.

Actually, just looking at Jos's tidy of your script, I can't see how you say it "didn't" help.

It clearly shows you put an EndIf above an Else with no matching If for the Else.

Thus cutting off the For/Next Loop. If you removed the EndIf above the Else (where you see the Tidy error of course), you'd see your problem go away.

Here's a suggestion if you are dead set against using Tidy for whatever insane reason. When you get errors like that, count the EndIf/WEnd/Next/etc... to see if they match the number of starting "If (not closed on one line of course)/While/For/etc..." statements.

In your case, you have 5 open "If" statements, with 6 closing "EndIf" statements :)


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Jos

I did try , alot. But it's very difficult trying to correct a problem when you can't find the problem. I looked over that script countless countless times and could never find anything to correct. Do you see anything wrong with it that would produce errors?

...me either.

But I also tried the Tidy thing you suggested. I was just letting you know that didn't work either.

Regardless , thank you for replying.

It is not a matter about just trying, but also about communicating what you tried and what your problem still is.

The output of Tidy really Clearly explains your problem and you need to start at the first reported error.

The script is your logic so its you that should understand where that ELSE belongs that is at the wrong place.

It will not help you when I correct your code for you because that would not help you for the future, so look at your script and see what the issues are reported by Tidy and solve them One at a time. Don;t forget to run Tidy again after making Each change.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Drew

I had the wrong idea on how Tidy worked. I apologize.

Share this post


Link to post
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
Sign in to follow this  

×