Progressbar Download

HDSInformatics

Member
Licensed User
Longtime User
Hi,

I have a download and upload button implemented in my app. Now when I download a database from my ftp server it takes about 5-10 seconds. In those few seconds I want that my app freezes and a progressbar appears and does the thing a progressbar is meant to do. How do I do this?

Any help?

Thanks

Michael
 

HDSInformatics

Member
Licensed User
Longtime User
Oke, i'll try to explain it with some code.
This is the code I use for my download button. When I download a file from the ftp server I would like to add a progressbar while it's downloading the file.

--> Click to Download <--
--> ------------------ = Progressbar <--
When completed message --> Done <--

Is this explained a bit better?

You'll probably notice my code isn't the best but please keep in mind that i'm just a beginner.

B4X:
'Download Code
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
Dim s As String
s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
'END
End Sub

'Download Code
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)

Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
FTP.DeleteFile(strSerialnumber)
'END
End Sub
'Download Button
Sub Download_Click
   Dim DateDMY As String
       DateDMY = DateTime.GetDayOfMonth (DateTime.now) & "-" & DateTime.GetMonth (DateTime.now) & "-" & DateTime.GetYear (DateTime.now) 
    Dim DateDMYUMS As String
       DateDMYUMS = DateTime.GetDayOfMonth (DateTime.now) & "-" & DateTime.GetMonth (DateTime.now) & "-" & DateTime.GetYear (DateTime.now) & "_" & DateTime.GetHour (DateTime.now) & "u" & DateTime.GetMinute (DateTime.now) & "m" & DateTime.GetSecond (DateTime.now) & "s"
          
      Dim strSerialnumber As String
      strSerialnumber = GetDeviceId 
      strSerialnumber = strSerialnumber & ".db" 
   Dim strDatumDownload As String
      strDatumDownload = "mapftp/" & DateDMYUMS
      strDatumDownload = strDatumDownload
   'Uncomment this to find out the serial number stored on DirRootExternal
   'FTP.DownloadFile("IGO.db", True, File.DirRootExternal, strSerialnumber)
   FTP.DownloadFile(strSerialnumber , True, File.DirRootExternal, strDatumDownload)
End Sub

Michael
 
Upvote 0

HDSInformatics

Member
Licensed User
Longtime User
Oke,

There is one problem, I am using the NET library downloaded from this thread that you posted. And I read a reply that you made in a different thread saying that if you activate both FTP and NET library that you'll encounter some problems because the FTP library is integrated in the NET library. And that is true, if I select them both i'm not able to download and/or upload twice. So you say that I need to use Magret's automated library but this will not work. Or can I use the NET library instead of the FTP one?

Hope I explained it so you understand!

Michael
 
Upvote 0

HDSInformatics

Member
Licensed User
Longtime User
Sorry to post 2 times in a row.

But i'm so confused. Why doesn't it all just work? hehe
The thing is, Magret's Automated FTP Library looks great! I would love to use it and implement this in my app! But the libray just doesn't work? I've deleted and re added the FTP library and also the NET library. If I checked correctly the NET is more recent than the FTP one.

Anyhow for example

NET library checked FTP unchecked

B4X:
written code in the Download_Click sub
If FTP.WiFi_IsConnected Then

after compiling and running

Compiling code. Error
Error compiling program.
Error description: Unknown member: wifi_isconnected
Occurred on line: 106
If FTP.WiFi_IsConnected Then
Word: wifi_isconnected

I know wifi_isconnected should works because this is written in Magret's thread post and this reply on her thread

Every ftp. ... That doesn't give an error
ftp.downloadfile
ftp.uploadfile
ftp.close
ftp.deletefile
ftp.initialize
ftp.isinitialized
ftp.list
ftp.passivemode
ftp.sendcommand
ftp.useSSL
And most of them i'm already using in my code and works like it should.


Looking at the forum thread Magret posted, there's alot more that just that.

If I uncheck NET and Check FTP . NOTHING works.... Tried everything Erel. I really need some help. Really Really hope you can help!
I think it'll be a mistake only newbies make. But everyone start off being a newbie :D!

Also I would like to add that i'm basing myself on a thread you posted in 2007 here is the link.


Michael
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
You stated in a post above that my Automated FTP library does not work. I use it every day. If you try to use it, no other FTP or NET library should be checked in the libraries TAB. It should provide just what you are looking for with the progress bars. You should test it with a new project with only the Core Library and my FTP Library checked. Once you have it working you can copy and paste that code into your project.

NOTE: You must also be using B4A version 2.5 or greater.
 
Last edited:
Upvote 0

HDSInformatics

Member
Licensed User
Longtime User
Thank you for replying.

I didn't mean to be rude about your library, i'm sure it works perfectly!
I just found out I still have version 2.3.
I hope we (my 2 co-workers and I) are eligible to download the 2.52 version :D
How do we download this? Send a mail to Erel?

Thank you

Michael
 
Upvote 0

HDSInformatics

Member
Licensed User
Longtime User
That depends on the type of license you purchased, see HERE

Yes I know, but I don't know what my schools financial director bought... We use b4a for a school project. We're working as interns and we need that new version to implement crucial objects for our app. We bought like 30 licenses if I recall correctly... Time is running out and I really need that update to use Margret's library... I can't finish what i'm doing without that library... I can try and contact Erel but like I said, time is running out...

Thanks anyways

Michael
 
Upvote 0
Top