Particle Posted December 21, 2007 Share Posted December 21, 2007 Heres the main code. $g_IP = @IPAddress1 TCPStartUp() Dim $MainSocket[7] If GuiCtrlRead($Checkbox1) = $GUI_CHECKED Then $MainSocket[0] = TCPListen($g_IP, 21, 100) If GuiCtrlRead($Checkbox2) = $GUI_CHECKED Then $MainSocket[1] = TCPListen($g_IP, 23, 100) If GuiCtrlRead($Checkbox3) = $GUI_CHECKED Then $MainSocket[2] = TCPListen($g_IP, 25, 100) If GuiCtrlRead($Checkbox4) = $GUI_CHECKED Then $MainSocket[3] = TCPListen($g_IP, 53, 100) If GuiCtrlRead($Checkbox5) = $GUI_CHECKED Then $MainSocket[4] = TCPListen($g_IP, 79, 100) If GuiCtrlRead($Checkbox6) = $GUI_CHECKED Then $MainSocket[5] = TCPListen($g_IP, 80, 100) If GuiCtrlRead($Checkbox7) = $GUI_CHECKED Then $MainSocket[6] = TCPListen($g_IP, 1080, 100) While 1 $msg = GuiGetMsg() For $i = 1 to $MainSocket[0] $ConnectedSocket = TCPAccept($MainSocket[$i]) If $ConnectedSocket >= 0 Then Dim $szIP_Accepted = SocketToIP($ConnectedSocket) _WritePort() SoundPlay("redalert.wav") ToolTip("" &@CRLF& "Client Connected - " & $szIP_Accepted &@CRLF& " ", 10, 10) Sleep(3000) _LogEdit() EndIf Next If $DiscButton = 1 or $msg = $Disc Then ExitLoop WEnd And when I compile to test run I get this error: >"D:\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "L:\Projects\Test.au3" L:\Projects\Test.au3 (313) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $ConnectedSocket = TCPAccept($MainSocket[$i]) $ConnectedSocket = TCPAccept(^ ERROR >Exit code: 1 Time: 5.872 I guess im not entirely understanding whats wrong with "$ConnectedSocket = TCPAccept($MainSocket[$i])", someone please help? Link to comment Share on other sites More sharing options...
Nahuel Posted December 21, 2007 Share Posted December 21, 2007 (edited) Well the array $MainSocket has 7 elements. when you do: For $i = 1 to $MainSocket[0] you exceed that number, since $MainSocket[0] doesn't have the number of elements of the array, but it contains a socket handle, which can be a number a lot greater than 7 Hope it's clear... Edited December 21, 2007 by Nahuel Link to comment Share on other sites More sharing options...
Particle Posted December 21, 2007 Author Share Posted December 21, 2007 Honestly i'm a little confused... Link to comment Share on other sites More sharing options...
GaryFrost Posted December 21, 2007 Share Posted December 21, 2007 Heres the main code. If GuiCtrlRead($Checkbox1) = $GUI_CHECKED Then $MainSocket[0] = TCPListen($g_IP, 21, 100) For $i = 1 to $MainSocket[0] For $i = 0 to 6 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Nahuel Posted December 21, 2007 Share Posted December 21, 2007 Thanks Gary Dim $MainSocket[7] --> here you declare an array of 7 elements. $MainSocket[0] = TCPListen($g_IP, 21, 100) --> here you assign the socket identifier to the 0 element of the array. This identifier (if i'm not wrong) is a number. For $i=0 to $MainSocket[0] -->will loop increasing the value of $i from 0 to whatever the number of the identifier is, when you only need it to do it up to 6. Use Garys suggestion. 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