home *** CD-ROM | disk | FTP | other *** search
/ DarkBasic Professional / DarkBasicPro.iso / data1.cab / Lang_Files_(English) / Help / examples / ftp / ftp1-example.dba < prev    next >
Encoding:
Text File  |  2004-09-22  |  1.3 KB  |  66 lines

  1. rem Ftp Showcase
  2.  
  3. rem Standard Setup Code for all examples
  4. set text font "arial" : set text size 20
  5. set text to bold : set text transparent
  6.  
  7. rem a pretty backdrop
  8. prettybackdrop()
  9.  
  10. rem Title
  11. center text screen width()/2,10,"FTP CONNECTION AND VIEW"
  12.  
  13. rem Connect to FTP
  14. gosub _connect
  15.  
  16. rem View FTP Files
  17. gosub _viewfiles
  18.  
  19. rem Disconnect from FTP
  20. ftp disconnect
  21.  
  22. rem Wait for exit
  23. print
  24. print "Press Any Key To Exit"
  25. wait key
  26. end
  27.  
  28. _connect:
  29.  url$="www.darkbasic.com"
  30.  user$="anonymous"
  31.  pass$="me@isp.com"
  32.  time#=timer()
  33.  set cursor 0,30
  34.  print "Connecting..." : sync
  35.  ftp connect url$,user$,pass$
  36.  if get ftp failure()=0
  37.   time#=timer()-time#
  38.   print "Connection established in ";time#/1000.0;" seconds."
  39.  else
  40.   print "Could not connect to ";url$
  41.   print "Error:";get ftp error$()
  42.   wait key
  43.   end
  44.  endif
  45. return
  46.  
  47. _viewfiles:
  48.  print "VIEW EACH FTP FILE IN A FOLDER"
  49.  if get ftp status()=1
  50.   print "FTP DIR:";get ftp dir$();"..." : sync
  51.   ftp find first
  52.   while get ftp file type()<>-1
  53.    print "Type:";get ftp file type();
  54.    print " Name:";get ftp file name$();
  55.    print " Size:";get ftp file size()
  56.    ftp find next
  57.    sync
  58.   endwhile
  59.  endif
  60. return
  61.  
  62. rem Pretty Backdrop Function
  63. function prettybackdrop()
  64.  box 0,0,640,480,rgb(0,128,128),rgb(128,0,0),rgb(128,0,128),rgb(128,128,0)
  65. endfunction
  66.