Jump to content

Program runs fine before compile; does not work after


Recommended Posts

I have a script that runs perfectly before compiling. I need one file called TCP.au3 included in this compiled program, but it does not seem to let me use it once I've compiled my main script.

I've noticed some people have had problems, but not like mine.

My GUI runs fine, but the back-end is at a stand still and does not run (I'm thinking because it is not getting the information from TCP.au3 it needs), but I could be wrong. Any help would be greatly appreciated.

Edited by JonBMN
Link to comment
Share on other sites

  • Moderators

JonBMN, you're stating you have a script that runs fine before compiling, but not after, and you would like some assistance. Yet, you do not provide us the script - so we have to guess at what you're doing and then troubleshoot why it is not working for you ;)

Please post your script, or a short reproducer of the problem; help us help you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Green.ico
#AutoIt3Wrapper_Outfile=ArchServer.exe
#AutoIt3Wrapper_Res_Comment=
#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****



#include "TCP.au3"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <Array.au3>
#include <ButtonConstants.au3>

;AutoItSetOption("TCPTimeout", 100)

;ToolTip("SERVER: Creating server...",10,30)

$hServer = _TCP_Server_Create(21230); A server. Tadaa!


Local $compName = "", $strSplit, $DateTime, $User, $CarDatabase = "Database.txt"
Local $MaxCars = 1000, $CarData[$MaxCars][3], $NumCars = -1, $List1, $List2, $List3, $List4
Local $ButtonAZ, $ButtonZA, $GUIhandle, $hChild_1, $ButtonCloseChild, $msg, $ConnectList
Local $UsersConnected = 0, $ActiveConnections, $Button19, $Button91


HotKeySet("{Esc}", "Quit")
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
;MAIN LINE





ReadCars()
GUI()

_TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server.
_TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects.
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Receive"); And this,... when we receive something from the client side


While 1
    $msg = GUIGetMsg(1)
        Switch $msg[1]
            Case $GUIhandle
                Switch $msg[0]
                  Case $GUI_EVENT_CLOSE
                      Quit()
                  Case $ButtonAZ
                      Sort("^ v", 0)
                  Case $ButtonZA
                      Sort("v ^", 0)
                  Case $Button19
                      Sort("^ v", 1)
                  Case $Button91
                      Sort("v ^", 1)
                EndSwitch
            Case $hChild_1
                 Switch $msg[0]
                     Case $GUI_EVENT_CLOSE
                          GUIDelete($hChild_1)
                 EndSwitch
         EndSwitch
WEnd

;END MAIN LINE

_TCP_Server_ClientList()


Func NewClient($hSocket, $iError); Yo, check this out! It's an $iError parameter! (In case you didn't noticed: It's in every function)
    $UsersConnected = $UsersConnected + 1
    _GUICtrlListBox_ReplaceString($ActiveConnections, 0, String($UsersConnected))
    If $UsersConnected > 1000 Then
        _TCP_Server_DisconnectClient($hSocket)
    EndIf
EndFunc

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
    $UsersConnected -= 1
    _GUICtrlListBox_ReplaceString($ActiveConnections, 0, String($UsersConnected))
EndFunc


Func Receive($hSocket, $sReceived, $iError)
    Local $LinesReceived[101]
    If $sReceived = " " Or $sReceived = "" Then
        Return
    EndIf
    ;ConsoleWrite($sReceived & @CRLF)
    $LinesReceived = StringSplit($sReceived, "|")
    For $Index = 1 to $LinesReceived[0]
        ParseLineData($LinesReceived[$Index])
    Next
EndFunc

Func ParseLineData($LineReceived)
    Local $Log = "", $FoundAt, $CheckIn, $LineSplit
    ConsoleWrite($LineReceived & @CRLF)
    MsgBox(0, "", $LineReceived & @CRLF)
    $LineSplit = StringSplit($LineReceived, ",")
    If $LineSplit[0] <> 4 Then
        _GUICtrlListBox_AddString($List4, "Received Incomplete Data String")
        return
    EndIf
    consoleWrite($LineSplit[0] & @CRLF)
    $DateTime = StringStripWS($LineSplit[1], 1)
    $User = StringStripWS($LineSplit[2], 1)
    $compName = StringStripWS($LineSplit[3], 1)
    $Data = StringStripWS($LineSplit[4], 1)
    $Data = StringStripWS($LineSplit[4], 2)
    $FoundAt = FindCar($compName)
    If $FoundAt = -1 Then
        _GUICtrlListBox_AddString($List4, "Found " & $compName & " not in the database. Adding Now.")
        $NumCars += 1
        $FoundAt = $NumCars
        $CarData[$NumCars][0] = $compName
        $CarData[$NumCars][1] = " "
        _GUICtrlListBox_ReplaceString($List2, $FoundAt, " " & $CarData[$NumCars][1])
        $CarData[$NumCars][2] = " "
        _GUICtrlListBox_ReplaceString($List3, $FoundAt, " " & $CarData[$NumCars][2])
        _GUICtrlListBox_ReplaceString($List1, $FoundAt, " " & $CarData[$FoundAt][0])
    EndIf
    $CarData[$FoundAt][1] = $DateTime
    _GUICtrlListBox_ReplaceString($List2, $FoundAt, " " & $CarData[$FoundAt][1])
    $strinstr = StringInStr($Data, "Heartbeat")
    If $strinstr > 0 Then
        $CheckIn = StringRight($Data, 2)
        $CarData[$FoundAt][2] = $CheckIn
        _GUICtrlListBox_ReplaceString($List3, $FoundAt, " " & $CarData[$FoundAt][2])
    EndIf
    $Log = FileOpen($compName & ".log", 1)
    FileWriteLine($Log, $LineReceived & @CRLF)
    ConsoleWrite($Data & @CRLF) ;;This is for testing purposes only;;
    ;sleep(500)
    FileClose($Log)
EndFunc

Func Quit()
    WriteCars()
    Exit
EndFunc

Func Sort($SortOrder, $SubItem)
    Local $Decending
    If $SortOrder = "^ v" Then
        $Decending = 0
    Else
        $Decending = 1
    EndIf
    _ArraySort($CarData, $Decending, 0, $NumCars, $Subitem)
    Repaint()
EndFunc

Func Repaint()
    For $Index = 0 To $NumCars Step 1
        _GUICtrlListBox_ReplaceString($List1, $Index, " " & $CarData[$Index][0])
        _GUICtrlListBox_ReplaceString($List2, $Index, " " & $CarData[$Index][1])
        _GUICtrlListBox_ReplaceString($List3, $Index, " " & $CarData[$Index][2])
    Next
EndFunc

Func WriteCars()
   Local $FileHandle, $Index
   $FileHandle = FileOpen($CarDatabase, 2)
   For $Index = 0 To $NumCars Step 1
      FileWriteLine($FileHandle, $CarData[$Index][0] & "," & $CarData[$Index][1] & "," & $CarData[$Index][2])
   Next
   FileClose($FileHandle)
EndFunc


Func ReadCars()
   Local $FileHandle, $Line, $LineStrip
   $FileHandle = FileOpen($CarDatabase, 0)
   While 1
      $Line = FileReadLine($FileHandle)
      If @error = -1 Then
         ExitLoop
      EndIf
   $NumCars += 1
   $LineStrip = StringSplit($Line, ",")
   $CarData[$NumCars][0] = $LineStrip[1]
   $CarData[$NumCars][1] = $LineStrip[2]
   $CarData[$NumCars][2] = $LineStrip[3]
   WEnd
   FileClose($FileHandle)
EndFunc

Func FindCar($LookFor)
   Local $Found = -1, $Index
   If $NumCars = -1 Then
      Return $Found
   EndIf
   For $Index = 0 To $NumCars Step 1
      If $LookFor = $CarData[$Index][0] Then
         $Found = $Index
         ExitLoop
      EndIf
   Next
   return $Found
EndFunc


Func GUI()
   Local $Index
   $GUIhandle = GUICreate("Archangel Log Collection", 1000, 750)
   GUICtrlCreateLabel("Sort Method:", 185, 13)
   GUICtrlCreateLabel("Sort Method:", 485, 13)
   $ButtonAZ = GUICtrlCreateButton("5", 250, 5, 30)
   GUICtrlSetFont($ButtonAZ, 10, 600, -1, "Webdings")
   $ButtonZA = GUICtrlCreateButton("6", 280, 5, 30)
   GUICtrlSetFont($ButtonZA, 10, 600, -1, "Webdings")
   $Button19 = GUICtrlCreateButton("5", 550, 5, 30)
   GUICtrlSetFont($Button19, 10, 600, -1, "Webdings")
   $Button91 = GUICtrlCreateButton("6", 580, 5, 30)
   GUICtrlSetFont($Button91, 10, 600, -1, "Webdings")
   GUICtrlCreateLabel("Computer Name", 60, 13)
   $List1 = GUICtrlCreateList("", 60, 35, 250, 650, BitOr($WS_BORDER, $WS_VSCROLL)) ;;$ES_READONLY incase you don't want to be able to select text
   GUICtrlCreateLabel("Date/Time", 360, 13)
   $List2 = GUICtrlCreateList("", 360, 35, 250, 650, BitOr($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
   GUICtrlCreateLabel("Speed Limit", 660, 13)
   $List3 = GUICtrlCreateList("", 660, 35, 250, 650, BitOr($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
   GUICtrlCreateLabel("Warning Window", 60, 680)
   $List4 = GUICtrlCreateList("", 60, 705, 850, 45, BitOr($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
   GUICtrlCreateLabel("Active Connections: ", 780, 680)
   $ActiveConnections = GUICtrlCreateList($UsersConnected, 880, 678, 30, 30)
   GUISetState(@SW_SHOW) ;shows the GUI window
   For $Index = 0 To $MaxCars Step 1
      _GUICtrlListBox_AddString($List1, " ")
      _GUICtrlListBox_AddString($List2, " ")
      _GUICtrlListBox_AddString($List3, " ")
   Next
   Repaint()
EndFunc

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
   Local $sData, $sFile, $cEdit_2
   #forceref $hWnd, $iMsg, $lParam
   $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
   $iCode = BitShift($wParam, 16) ; Hi Word
   Switch $iCode
     Case $LBN_DBLCLK
         Switch $iIDFrom
             Case $List1
                 $sData = GUICtrlRead($List1) ; Use the native function
                 $sData = StringStripWS($sData, 1) ;strips the space before the data
                 $sFile = FileRead($sData & ".log") ; Read the file
                 $hChild_1 = GUICreate($sData & " - Log", 500, 500, 600, 0, Default, Default, $GUIhandle)
                 $cEdit_2 = GUICtrlCreateEdit("", 10, 10, 480, 480, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
                 GUICtrlSetData($cEdit_2, $sFile)
                 GUISetState()
                 ControlSend($hChild_1, "", $cEdit_2, "^{HOME}") ; This unselects the text

         EndSwitch
EndSwitch
EndFunc

Edited by JonBMN
Link to comment
Share on other sites

  • Moderators

Is tcp.au3 in the same directory as your script? Have you tried putting in the whole path to the include file (C:......TCP.au3)?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Also to add, this works with a client that will not send unless the connection is active. The client is sending when I have the compiled server running I am just not getting a single message on my GUI. Any suggestions on why that is?

Link to comment
Share on other sites

I did a quick and dirty example and compiled it and ran it and it completely worked.

#include "TCP.au3"


HotKeySet("{Esc}", "Quit")
$hServer = _TCP_Server_Create(21230); A server. Tadaa!

_TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server.
_TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects.
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Receive"); And this,... when we receive something from the client side

While 1

WEnd



Func NewClient($hSocket, $iError); Yo, check this out! It's an $iError parameter! (In case you didn't noticed: It's in every function)
EndFunc   ;==>NewClient

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
EndFunc   ;==>Disconnect

Func Receive($hSocket, $sReceived, $iError)
    MsgBox(0, "", $sReceived)
EndFunc   ;==>Receive

Func Quit()
    Exit
EndFunc   ;==>Quit

What's different that it won't work in my script in my post above, but will work in this little example?

Link to comment
Share on other sites

What messages, if any, do you get when compiling the script? Does it mention the use of Call or Execute?

One other thing, you have these lines

WEnd

;END MAIN LINE

_TCP_Server_ClientList()

The last line won't get executed because it's after the While loop, and your script never leaves the While loop, so it never gets to that line.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@BrewManNH I do not want it to execute. I just put it there so that I might use it later, but forgot to take it out after I was done.

the errors I get say that the _TCP_Send function from the TCP.au3::

-### StripOnly/StripFunc Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by this Function.

>### current Func: ___TCP_OnAccept

C:UsersJonBecherDesktopTCPServer100TCP.au3(139,1) Warning for line:Call($__TCP_SOCKETS[0][6], 0, $iError)

Link to comment
Share on other sites

There you go, it told you why it won't run, and you ignored it.

There are ways to prevent this from causing problems when using /striponly. If you add this line #Obfuscator_Ignore_Funcs= at the top of the TCP.au3 file, and add in the names of the functions that get stripped out because of the Call statement, you can avoid this and still use the /striponly part of obfuscator.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Developers

@BrewManNH I do not want it to execute. I just put it there so that I might use it later, but forgot to take it out after I was done.

the errors I get say that the _TCP_Send function from the TCP.au3::

-### StripOnly/StripFunc Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by this Function.

>### current Func: ___TCP_OnAccept

C:UsersJonBecherDesktopTCPServer100TCP.au3(139,1) Warning for line:Call($__TCP_SOCKETS[0][6], 0, $iError)

So you seriously thought you could ignore these and expect your script to run ...huh ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It's running without that so yes I did.

PS: if you can't respond courteously then don't respond at all. Basic rules you learn in 1st grade. Do you want me to come into your topic and make you feel stupid when the question has already been answered? No I didn't think so, also we already had this whole discussion on an old topic how you don't need to be rude especially when your not even answering a question.

Edited by JonBMN
Link to comment
Share on other sites

  • Developers

It's running without that so yes I did.

PS: if you can't respond courteously then don't respond at all. Basic rules you learn in 1st grade. Do you want me to come into your topic and make you feel stupid when the question has already been answered? No I didn't think so, also we already had this whole discussion on an old topic how you don't need to be rude especially when your not even answering a question.

Think we went down this road before if my memory serves me right, but won't drag it too long this time.

I have learned never to ignore statements that explicitly tell you that your script will be crippled.

That is all I am contributing here today and wish you success ignoring warnings I have programmed in Obfuscator, but please do not moan about it when it doesn't work, since you are informed about it. ;)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If we went down this road again, then why did you do it again? I literally do not understand why you think it is okay to make a rude statement when the question has already been answered. Not once did I moan and groan about how it didn't work. I didn't understand it and therefore I asked a question about it. I don't understand how you think everyone is suppose to be a god when it comes to autoIT and know exactly how to read and fix errors that come up.

That's why these forums are here, TO ASK QUESTIONS ABOUT THINGS YOU DO NOT UNDERSTAND. Not get criticized when your just looking for an answer to a question (that you have done a ton of work on might I add). I thought I did good debugging in which I found what was not letting me run it and then asked how to fix it, then got the push in the right direction and went to work. I don't understand how you think you are justified to come into someones post when what you said has already been stated by someone else, and then bash them for making a little mistake that they are in the process of trying to fix.

You say you don't want this to drag on, but yet you still make YET ANOTHER rude comment, "wish you success ignoring warnings". Seriously what is your problem? Do you wish to just piss everyone away from autoIT or what? Have some respect just like you'd want.

Link to comment
Share on other sites

If I've ever seen a 12 year its you. Saying whatever instead of explaining yourself to me without making a condescending statement like an adult is utterly childish. Don't respond to topics that don't need your help, especially if your just going to be an asshole and make yourself look like you have god complex if I've ever seen one.

Link to comment
Share on other sites

  • Developers

Funny to see you doing the exact same thing as the other thread and you think I have a problem?

This thread has run it's course.

*Click*

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...