forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


VDSIPP - HTTP download fails if network is slow
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
dank
Newbie


Joined: 09 Jul 2001
Posts: 2
Location: Canada

PostPosted: Fri Nov 22, 2002 10:34 pm    Post subject: VDSIPP - HTTP download fails if network is slow Reply with quote

Hello all

I am using VDSIPP to download a small (1k) txt file from my own web site. It works great from high speed Cable Internet. It often fails (40%) when I am using a DSL Internet connection and it always fails on a 56k modem. When it fails my saved file contains the standard 404 page not found message.

Can anyone tell me how I can use HTTP to reliably download simple text files, and maybe binary files too?

My sample code is as follows

Title HTTP Download Test
rem my id is not xxxx of course
external vdsipp.dll,xxxx|Dan
%%url = http://mysite.com/myfile.dat
%%file = c:\temp\myfile.dat

INTERNET HTTP,CREATE,1
INTERNET HTTP,THREADS,1,off
INTERNET HTTP,PROTOCOL,1,1
INTERNET HTTP,USERAGENT,1,HTTPtest
INTERNET HTTP,DOWNLOAD,1,%%url,%%file
INTERNET HTTP,DESTROY,1

_________________
DanK
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Nov 22, 2002 10:40 pm    Post subject: Reply with quote

If you turn threads ON, you can WAIT a few seconds
for the event before using the DESTROY command.

This should wait up to 20 seconds, but will close
immediately if the download is completed before
then (adjust the WAIT time to whatever you need)...
Code:

INTERNET HTTP,CREATE,1
INTERNET HTTP,THREADS,1,ON
INTERNET HTTP,PROTOCOL,1,1
INTERNET HTTP,USERAGENT,1,HTTPtest
%e = @event()
INTERNET HTTP,DOWNLOAD,1,%%url,%%file
WAIT EVENT, 20
INTERNET HTTP,DESTROY,1

Or ya might just insert a simple WAIT with threads OFF....

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Nov 22, 2002 11:35 pm    Post subject: Reply with quote

BTW, your example works fine on my system as is
(except for changing the URL of course).

I have a 56k modem, but only a 28k line connection...

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
dank
Newbie


Joined: 09 Jul 2001
Posts: 2
Location: Canada

PostPosted: Sat Nov 23, 2002 3:08 am    Post subject: Reply with quote

Thank you very much for your help.
It works perfect now.

Dan

_________________
DanK
Back to top
View user's profile Send private message Visit poster's website
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 9:35 am    Post subject: Reply with quote

Is there a wayt to make a progress dialog when using the download command with VDSIPP ?
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Feb 19, 2003 9:42 am    Post subject: Reply with quote

Look in the help file under "HTTP client functions".

You should be able to get the file content length, and
use TRANSFERBYTES to check the current file size.

To put this in a progress bar (uses 0 - 100), do the math
to convert the file size into hundredths, then set the progress
bar accordingly... Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 9:49 am    Post subject: Reply with quote

Sounds great.
Thanks alot Mac.

How does this look, see any errors?
Code:
rem This is my first go at using any extension at all with VDS.
rem I've only been using VDS for about three days now and love it more each time I use it :)

%%Title = GeoTrail Downloader
%%Version = 1.0
Title %%Title
  DIALOG CREATE,%%Title,-1,0,473,110
  DIALOG ADD,GROUP,GROUP1,8,8,448,48,Download File
  DIALOG ADD,EDIT,EDIT1,24,16,432,24,http://www.geotrail.no/lastned/geoamp.zip
  DIALOG ADD,BUTTON,BUTTON1,64,280,88,24,&Save file as
  DIALOG ADD,BUTTON,BUTTON2,64,376,90,24,Start &download
  DIALOG ADD,STATUS,STATUS1,Remember to click on @CHR(34)Save file as@CHR(34) before downloading.
  DIALOG SHOW
  DIALOG DISABLE,BUTTON2

rem Calls the extenion into memory.
EXTERNAL VDSIPP.DLL

:EVLOOP
  WAIT EVENT
  goto @event()
 
:BUTTON1BUTTON
%F = @DIRDLG(Select where you want to download the file.)
If %F
DIALOG SET,STATUS1,%F
  DIALOG ENABLE,BUTTON2
  DIALOG DISABLE,BUTTON1
goto EVLOOP
Else
info You MUST select where you want to download the file@cr()by clicking the @CHR(34)Save file as@CHR(34) button.
End
goto EVLOOP

:BUTTON2BUTTON
If %F
DIALOG DISABLE,BUTTON1
DIALOG DISABLE,BUTTON2
DIALOG SET,STATUS1,Download in progress...
%%URL = @dlgtext(EDIT1)
INTERNET HTTP,CREATE,1
INTERNET HTTP,THREADS,1,OFF
INTERNET HTTP,PROTOCOL,1,1
INTERNET HTTP,USERAGENT,1,"VDSWORLD Downloader"
INTERNET HTTP,DOWNLOAD,1,%%URL,%F\geoamp.zip
%S = @INTERNET(HTTP,CONTENT-LENGTH,1)
%%FileSize = @DIV(%S,1024)
INTERNET HTTP,DESTROY,1
DIALOG SET,STATUS1,Download completed!
info Download complete.@cr()@cr()The file %%URL@cr()have now been saved to@cr()%F@cr()Filesize:@cr()%%FileSize kb
DIALOG ENABLE,BUTTON1
DIALOG ENABLE,BUTTON2
goto Close
Else
info You MUST select where you want to download the file@cr()by clicking the @CHR(34)Save file as@CHR(34) button.
goto EVLOOP
End
 
:Close
  Exit


PS! I haven't tried to add the progressbar yet. SOunds abit too complicated at the time Wink

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Feb 19, 2003 10:05 am    Post subject: Reply with quote

Not offhand, but I can barely read my own code if it's
not fresh in my memory... Laughing

One thing ya should do is indent your code - makes it easier
to read and match IF/ENDs etc. You can use whatever system
ya want - I usually indent two spaces on everything except IFs,
then I use three to keep them lined up...
Code:

:Label
  if @file(myfile)
     INFO File found..
  else
     WARN Cannot find file...
  end

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 10:10 am    Post subject: Reply with quote

Doesn't I have matching if's and end's ?

And I'm cleaning up the code as I type Wink

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Wed Feb 19, 2003 10:11 am    Post subject: Reply with quote

Heres the Progress Bar Code:

You should put this in the timer section of your code:

e.g

change evloop to:

:evloop
wait event,1
goto @event()
:timer
rem insert code here
rem this event will be run every 1 second
goto evloop
Code:

rem retrieve the total size to transfer
%%size = @internet(http,content-length,1)
rem retrieve the amount of bytes left to transfer
%%left = @internet(http,transferbytes,1)
    %%per = @fdiv(100,%%size)
  %%per1 = @fmul(%%per,%%left)
  %%per2 = @format(%%per1,9.0)
rem P2 is dialog name for the progress bar
  dialog set,p2,%%per2


Hope this helps

Nathan


Last edited by Rubes_sw on Wed Feb 19, 2003 10:13 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 10:12 am    Post subject: Reply with quote

Isn't it possible to diable a filemenu?
I can't seem to get that working.
I've added this after the start of the download procedure:

Code:
  DIALOG DISABLE,Help

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Feb 19, 2003 10:16 am    Post subject: Reply with quote

LOL, I didn't say ya had any mismatched IF/ENDs - I was
just gettin' cross-eyed tryin' to check it with nothing indented
on the bottom half... Shocked

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361


Last edited by Mac on Wed Feb 19, 2003 10:16 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 10:16 am    Post subject: Reply with quote

Hi Nathan. Thanks for the code.
But how does the program know what filename to check?

Rubes_sw wrote:
Heres the Progress Bar Code:

You should put this in the timer section of your code:

e.g

change evloop to:

:evloop
wait event,1
goto @event()
:timer
rem insert code here
rem this event will be run every 1 second
goto evloop
Code:

rem retrieve the total size to transfer
%%size = @internet(http,content-length,1)
rem retrieve the amount of bytes left to transfer
%%left = @internet(http,transferbytes,1)
    %%per = @fdiv(100,%%size)
  %%per1 = @fmul(%%per,%%left)
  %%per2 = @format(%%per1,9.0)
rem P2 is dialog name for the progress bar
  dialog set,p2,%%per2


Hope this helps

Nathan

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 10:17 am    Post subject: Reply with quote

Mac wrote:
LOL, I didn't say ya had any mismatched...


Aaa OK. he he he, sorry.

Now I'm trying to get this progress thing to work... Twisted Evil

VDS is just so cool.
I hate myself for not trying it before now Wink

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Feb 19, 2003 10:19 am    Post subject: Reply with quote

From the VDS help file:

Note: MENUs are not implemented in the same way as other dialog elements. The SET, CLEAR, HIDE, SHOW, ENABLE, DISABLE and REMOVE verbs don't work with them. Once a menu is added to a dialog it is fixed.

Copyright ©1995 - 2000 S.A.D.E. s.a.r.l. / All rights are reserved.


Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group