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 


Download program w/progress (uses vdsipp)...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


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

PostPosted: Wed Feb 19, 2003 1:28 pm    Post subject: Download program w/progress (uses vdsipp)... Reply with quote

Here's a program to download files with a progress bar
(if size is available from server), bytes downloaded, and
approx kb/sec of transfer.

Thanks to GeoTrail for the inspiration.

Just finished this - let me know if ya find any bugs.
Code:

EXTERNAL @path(%0)VDSIPP.DLL

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Mac's Download Program",0,@diff(@div(@sysinfo(SCREENWIDTH), 2), 162),330,92,RESIZABLE
  %%hwnd = @winexists("Mac's Download Program")
  DIALOG ADD,STYLE,S1,MS Sans Serif,8,B
  DIALOG ADD,TEXT,T1,8,25,,,"URL",,S1
  DIALOG ADD,EDIT,E1,5,55,205,20
  DIALOG ADD,BUTTON,Dload,5,265,55,20,,,S1

  DIALOG ADD,TEXT,T2,33,4,,,"Save as",,S1
  DIALOG ADD,EDIT,E2,30,55,205,20
  DIALOG ADD,BUTTON,Browse,30,265,55,20,,,S1

  DIALOG ADD,PROGRESS,Prog,55,55,265,15
  DIALOG ADD,TEXT,Stat1,56,15,,,"",,S1
  DIALOG ADD,STATUS,Stat2,,S1
DIALOG SHOW

:RESIZE
  rem -- minimum width --
  if @greater(205, @winpos(%%hwnd, W))
     DIALOG SETPOS,,,,200
  end
  rem -- keep height same -
  DIALOG SETPOS,,,,,95
  DIALOG SETPOS,Dload,,@diff(@winpos(%%hwnd, W), 68)
  DIALOG SETPOS,Browse,,@diff(@winpos(%%hwnd, W), 68)
  DIALOG SETPOS,E1,,,@diff(@winpos(%%hwnd, W), 130)
  DIALOG SETPOS,E2,,,@diff(@winpos(%%hwnd, W), 130)
  DIALOG SETPOS,Prog,,,@diff(@winpos(%%hwnd, W), 68)
:EVLOOP
  if %%dload
     WAIT EVENT, 1
  else
     WAIT EVENT
  end
  goto @event()

:TIMER
  %%bit = @internet(HTTP, TRANSFERBYTES, 1)
  if @numeric(%%size)
     %%percent = @diff(100, @div(@diff(%%size, %%bit), %%incr))
     DIALOG SET, Prog, %%percent
     DIALOG SET, Stat1, %%percent"%"
  end
  if @greater(%%bit, 0)
     if @greater(%%bit, %%lastbit)
        %%rate = @format(@fdiv(@diff(%%bit, %%lastbit), 1000), .2)
     else
        %%rate = "unknown"
     end
     %%lastbit = %%bit
  end
  DIALOG SET, Stat2, %%bit of %%size bytes. %%rate" kb/sec."
  goto EVLOOP

:BrowseBUTTON
  %%file = @filedlg(,,,SAVE)
  if %%file
     DIALOG SET, E2, %%file
  end
  goto EVLOOP

:DloadBUTTON
  if @not(@dlgtext(E1))@not(@dlgtext(E2))
     WARN "You must have both 'URL' and 'Save as' entries..."@tab()
     goto EVLOOP
  end
  rem -- in case user made changes --
  %%size = "unknown"
  %%url = @dlgtext(E1)
  %%file = @dlgtext(E2)
  %%dload = 1
  INTERNET HTTP, CREATE, 1
  INTERNET HTTP, THREADS, 1, ON
  INTERNET HTTP, PROTOCOL, 1, 1
  INTERNET HTTP,GETHEADER, 1, %%url, %%file
  goto EVLOOP

:HTTP1ONGETHEADERDONE
  %%size = @internet(HTTP, CONTENT-LENGTH, 1)
  if @greater(%%size, 0)
     %%incr = @div(%%size, 100)
  else
     %%size = "unknown"
     DIALOG SET, Stat1, "???%"
  end
  DIALOG SET, Stat2, %%size bytes
  INTERNET HTTP, DOWNLOAD, 1, %%url, %%file
  goto EVLOOP

:HTTP1ONDOWNLOADDONE
  DIALOG SET, Prog, 100
  DIALOG SET, Stat1, "100%"
  if @file(%%file)
     DIALOG SET, Stat2, @file(%%file, Z) bytes downloaded
  end
  INFO Download complete...@tab()
  DIALOG CLEAR, Prog
  DIALOG CLEAR, Stat1
  DIALOG CLEAR, Stat2
  %%dload = ""
  %%size = ""
  %%bit = ""
  %%rate = ""
  INTERNET HTTP, DESTROY, 1
  goto EVLOOP

:CLOSE
  if %%dload
     INTERNET HTTP, DESTROY, 1
  end
  EXIT

EDIT1 - Added code to display actual file size when download is complete.
EDIT2 - Changed @filedlg() "OPEN" window to "SAVE AS".
EDIT3 - Added kb/sec, made window width resizable, and now shows
bytes received even if file size is unknown.

Cheers, Mac

_________________
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 Mon Mar 10, 2003 4:01 pm; edited 4 times 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: 571
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 1:36 pm    Post subject: Reply with quote

Works great here.
WinXP Pro SP1

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 2:28 pm    Post subject: Reply with quote

Added code to display actual file size (as bytes downloaded)
when download is complete.

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
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2144
Location: A House

PostPosted: Wed Feb 19, 2003 8:50 pm    Post subject: Reply with quote

Worked great on Win98SE with it's guts ripped out by 98Lite Pro.

BTW, I now have a new found respect for the older 95 versions. I had
installed 95 OSR2, but it didn't have the drivers I needed, so I had to
install 98SE, and then I ripped out the IE integration and other Junk with
98Lite Pro. It sure did pick up the speed as opposed to trying to run a
default MS install of 98SE or the nasty beast WinME.

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
http://www.freewarehome.com <-- Freeware listings since 1996
Back to top
View user's profile Send private message
GeoTrail
Valued Contributor
Valued Contributor


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

PostPosted: Wed Feb 19, 2003 8:58 pm    Post subject: Reply with quote

98 Lite Pro? Know where I could download that?
Would be cool to use on my old laptop Smile

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2144
Location: A House

PostPosted: Wed Feb 19, 2003 9:13 pm    Post subject: Reply with quote

http://www.98lite.net/

They have a freeware version also. And be sure to pay close attention
to instructions while using this.

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
http://www.freewarehome.com <-- Freeware listings since 1996
Back to top
View user's profile Send private message
GeoTrail
Valued Contributor
Valued Contributor


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

PostPosted: Wed Feb 19, 2003 9:40 pm    Post subject: Reply with quote

Thanks Very Happy
_________________
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: Thu Feb 20, 2003 12:52 am    Post subject: Reply with quote

Garrett wrote:
BTW, I now have a new found respect for the older 95 versions.
-Garrett

LOL, I oughtta print this out and frame it.... Laughing Laughing Laughing

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: 571
Location: Bergen, Norway

PostPosted: Thu Feb 20, 2003 1:07 am    Post subject: Reply with quote

Laughing
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2144
Location: A House

PostPosted: Fri Feb 21, 2003 12:14 am    Post subject: Reply with quote

Mac wrote:
Garrett wrote:
BTW, I now have a new found respect for the older 95 versions.
-Garrett

LOL, I oughtta print this out and frame it.... Laughing Laughing Laughing

Cheers, Mac Smile


Yeah Mac, I knew you'd get a kick outta seeing me say that.

I've got a new campaign slogan now, similar to the "Be like Mike"
campaigns of days gone by.

"Be Like Mac!" and use Windows 95!

-Garrett
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


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

PostPosted: Fri Feb 21, 2003 12:17 am    Post subject: Reply with quote

ROFL Laughing Laughing Laughing
_________________
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: 571
Location: Bergen, Norway

PostPosted: Fri Feb 21, 2003 12:49 am    Post subject: Reply with quote

He he he nice one.

I can't even install 95 on this machine Sad Not compatible. The computer just crashes during installation he he he
But my old 265 MHz laptop can "handle" it 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: Mon Mar 10, 2003 4:00 pm    Post subject: Reply with quote

Made some modifications to code:

1. Added approx kb/sec.
2. Made window width resizable.
3. Now shows bytes received even if file size is unknown.

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 -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
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