Jump to content
Sign in to follow this  
Monica

Control Upload progress

Recommended Posts

Monica

Hi all!! :(

I'm writing a small FTP uploader app, very simple, using only the embedded UDF functions.

So, I use _FTP_Open -> open my connection, _FTP_DirSetCurrent -> set correctly current dir, _FTP_ProgressUpload -> upload my files with progress bar, and finally _FTP_Close for close the connection.

All works great great great! :mellow:

But i want to customize the progress text and title that appear during the upload.

The only way i find is to specify a custom function in _FTP_ProgressUpload function.

I've tested this code:

_FTP_ProgressUpload($conn, $aFile, $remoteFileName, "_Update_Progress(10)")

but it falis! :lol:

The function "_Update_Progress" is the same in the online help, but i don't understand HOW IT WORKS:

Func _UpdateProgress($Percentage)
                      GUICtrlSetData($ProgressBarCtrl,$percent)
                      Switch GUIGetMsg()
                      Case $GUI_EVENT_CLOSE
                            Return -1 ; _FTP_UploadProgress Aborts with -1, so you can exit you app afterwards
                        Case $Btn_Cancel
                           Return 0 ; Just Cancel, without special Return value
                      EndSwitch
                      Return 1 ; Otherwise contine Upload
Endfunc

Anyone help me? Thanks!!!

Monica

Edit: I've tried to put a msgBox at the beginning of the called function but nothing happen! Why the function isn't called???

Edited by Monica

Share this post


Link to post
Share on other sites
PsaltyDS

Just provide the name of the function to call, without parens or parameters:

_FTP_ProgressUpload($conn, $aFile, $remoteFileName, "_Update_Progress")

The function will be called with the percentage added as a parameter. For this example, at 51%, it would called internally by:

$ret = Call("_Update_Progress", 51)

That entry in the help file sucks. Hopefully it will be cleaned up soon.

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Monica

Bingo! :( Great, all works with MY progress bar now!!! I love it!

Thanks PsaltyDS, so much... I want to post my (simple simple) code, if helpful for someone, but i must tell you that this function (_FTP_ProgressUpload) has not an optimal GUI management, sigh! If the file size is > 20 MB, all the bytes are trasmitted correctly to server, but my main autoIt3 window freeze many times, and i must try several times to click the stop button till it work and stop my upload. Have you any idea how to prevent this? (I'm thinking something like VB doEvents function called on main window...) :mellow: My code:

In main function, just create (in a global var) a progress bar control:

Global $progress, $buttonstopUpload
$progress = GUICtrlCreateProgress(9, 310, 338, 10) ;progress upload bar
$buttonstopUpload = GUICtrlCreateButton("Stop", 340, 323)

In the GUI events management: nothing

The upload funcion call:

if (_FTP_ProgressUpload($conn, $aFile, $remoteFileName, "_UpdateProgress")) Then
            MsgBox(0, "OK", "File successfully uploaded!")
            GUICtrlSetData($progress, 0)
        Else ;[if @error = -6 then button stop pressed]
            MsgBox(0, "ERROR", "Error during upload (error code: " & @error & ").")
            GUICtrlSetData($progress, 0)
        EndIf

The function _UpdateProgress:

Func _UpdateProgress($percent)
                      GUICtrlSetData($progress, $percent)
                      Switch GUIGetMsg()
                        Case $buttonstopUpload
                           Return 0 ; Just Cancel
                      EndSwitch
                      Return 1 ; Otherwise contine Upload
Endfunc

Bye!

Monica

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  

×