Jump to content

Need help with Filetransfer


 Share

Recommended Posts

Hi everybody I have a problem with this script when I press wait for file then I get error can not lock port does anyone know what is causing this? I hope someone has a solution because it is not possible to lock the gate. Same thing when I try to send a file I do not know what it may be but hope for a response from someone here as I know that there are many knowledgeable freinds here.

Filetransfer.au3

Link to comment
Share on other sites

  • Developers
12 minutes ago, Borje said:

I am not sure how to debug this.

What is the question exactly? You don't know how to add ConsoleWrites to the code to see what is happening?

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

I'd guess right now your main problem is that you never call TCPStartup... it's wrapped in a function named OnAutoItStart. That function doesn't get called automagically though. You either need to use #OnAutoItStartRegister OnAutoItStart or call OnAutoItStart() at the top of your script.

Also, remove all of the Global Const lines and add #include <GUIConstants.au3> at the top of your script. No need to reinvent the wheel or worry about adding more constants later as you need them.

If you wrote this script yourself, I'll offer more suggestions, but I get the feeling you didn't, so I won't overload you :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

3 hours ago, seadoggie01 said:

I'd guess right now your main problem is that you never call TCPStartup...

This is most likely to be one/the main? problem.

23 hours ago, Borje said:

I dont know how to add consolwrite i have never doing that before.

Besides ConsoleWrite you can also use _FileWriteLog for debugging (the principle is similar).
As I do not want to fiddle around in your original script, I created an example for you on the fly ;):

#include <File.au3> ; for the LOGFile
OnAutoItExitRegister("_MyExitFunc")
Global $hLOGFile = FileOpen(@ScriptDir & "\Example.log", 2) ; 2=Write mode (erase previous contents)
OnAutoItStart()

_FileWriteLog($hLOGFile, "==> START PROGRAM")

_FileWriteLog($hLOGFile, "Before _MAIN")
_Main()
_FileWriteLog($hLOGFile, "After _MAIN")


Func _Main()
    Local $iGuiMsg, $btnExit, $btnInfo, $sIPInfo, $sDomain
    GUICreate("Just a Dummy :) ", 500, 120, -1, -1)
    $btnExit = GUICtrlCreateButton("Exit", 20, 20, 200, 40)
    $btnInfo = GUICtrlCreateButton("Info", 260, 20, 200, 40)
    GUISetState()
    While 1
        $iGuiMsg = GUIGetMsg()
        Select
            Case $iGuiMsg = -3 ; = $GUI_EVENT_CLOSE
                _FileWriteLog($hLOGFile, "$GUI_EVENT_CLOSE")
                ExitLoop
            Case $iGuiMsg = $btnExit
                _FileWriteLog($hLOGFile, "Exit-Button pressed")
                ExitLoop
            Case $iGuiMsg = $btnInfo
                _FileWriteLog($hLOGFile, "Info-Button pressed")

                ; just to check TCP :
                $sDomain = "www.autoitscript.com"
                $sIPInfo = TCPNameToIP($sDomain)
                If @error Then
                    $sIPInfo = "TCPNameToIP failed"
                    MsgBox(BitOR(4096, 16), $sDomain, "IP= " & $sIPInfo)
                    _FileWriteLog($hLOGFile, $sDomain & " -> TCPNameToIP failed")
                Else
                    MsgBox(BitOR(4096, 64), $sDomain, "IP= " & $sIPInfo)
                    _FileWriteLog($hLOGFile, $sDomain & " -> TCPNameToIP success")
                EndIf
        EndSelect
    WEnd
    GUIDelete()
EndFunc ;==>_Main

; --------------------------------------------------------------------
Func OnAutoItStart()
    _FileWriteLog($hLOGFile, "==> Func : OnAutoItStart")
    TCPStartup()
EndFunc

Func OnAutoItExit()
    _FileWriteLog($hLOGFile, "==> Func : OnAutoItExit")
    TCPShutdown()
EndFunc
; --------------------------------------------------------------------

; --------------------------------------------------------------------
; Your Exit Function
; --------------------------------------------------------------------
Func _MyExitFunc()
    OnAutoItExit()

    ; Close Logfile
    _FileWriteLog($hLOGFile, "==> EXIT PROGRAM")
    If $hLOGFile Then FileClose($hLOGFile)
EndFunc   ;==>_MyExitFunc

You can set a remark via _FileWriteLog($hLOGFile, "...")  at any point of the script, which will then be written to the Logfile (for further analysis).

Note : You have to be a bit careful with the macros @error and @extended. _FileWriteLog ( similar to ConsoleWrite) changes/resets these macros. It is therefore advisable to save them in variables (e.g. $iError=@error and $iExtended=@extended) for further processing.

Edited by Musashi
Response expanded

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Hi seadoggie01 and thanks you very much yes I have never call the  TCPStartup now it is working I have used this script long time before and it working good with 3.3.0.0, after I change autoit version to 3.3.14.5 i have this problems,   But now all works perfect and I have learn little more.   

Thanks to Musasci for debugging script.

        

Link to comment
Share on other sites

v3.3.4.0
Some of the following features are deprecated. ....

OnAutoItStart() has been removed. See the new pre-processor statement #OnAutoItStartRegister. 
OnAutoItExit() has been removed. See the new functions OnAutoItExitRegister() and OnAutoItExitUnRegister().

If you don't code often, these are hard to catch.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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...