better, read the header
;;; FUNCTION
;;; downloads a file specified by a URL
;;; could be used to update a custom program or about
;;; 100 different things
;;;
;;; ARGUMENTS
;;; strURL = valid URL
;;; i.e. "http://www.myfiles.com/README.txt"
;;;
;;; USAGE
;;; (MST-GetFileFromURL "http://www.theswamp.org/lilly.pond/public/GetFileFromURL.txt")
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Copyright© 2003 Mark S. Thomas
;;; mark.thomas@theswamp.org
;;;
;;; VERSION
;;; 0.9 Mon Sep 22, 2003
;;; 0.95 Mon Sep 22, 2003
;;;
;;; NOTE
;;; valid and non valid URL's
;;; (vla-IsURL utilobj "\\DPW\SYS\USERS\PW2N\file.txt"):vlax-false
;;; (vla-IsURL utilobj "C:\\temp\Text Document.txt"):vlax-false
;;; (vla-IsURL utilobj "file://C:\\temp\Text Document.txt"):vlax-true
;;; (vla-IsURL utilobj "file://\\DPW\SYS\USERS\PW2N\file.txt"):vlax-true
(defun MST-GetFileFromURL (strURL / vlUtilObj RemoteFile TmpFile strNewFile
strFileBase strFileExt NewFile)
(setq vlUtilObj
(vla-get-Utility
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
(if
(and
(= (type strURL) 'STR)
(= (vla-IsURL vlUtilObj strURL) :vlax-true)
)
(setq RemoteFile
(vl-catch-all-apply
'vlax-invoke-method
(list
vlUtilObj
'GetRemoteFile
strURL
'TmpFile
:vlax-false
)
)
)
); if
(if
(vl-catch-all-error-p RemoteFile)
(alert "Remote file not found, contact author of this program")
; else
(progn
(setq strFileBase (vl-filename-base TmpFile)
strFileExt (vl-string-left-trim "."(vl-filename-extension TmpFile))
strNewFile (strcat (vl-filename-base TmpFile)(vl-filename-extension TmpFile))
)
); progn
); if
(if strNewFile
(setq NewFile
(getfiled "Save File To:" strNewFile strFileExt 1)
)
)
(if
(not (vl-file-copy TmpFile NewFile nil))
(alert "There was a problem saving the file, make sure a duplicate does not exist")
; else
(vl-file-copy TmpFile NewFile nil)
); if
(prompt
(strcat "\nOriginal downloaded file = "TmpFile)
)
(princ)
); defun
;;; Last change: 2003 Sep 22
;;; Timestamp: <MST-GetFileFromURL.lsp Mon 2003/09/22 13:10:17 PC16883>
;;; vim:tw=78:ts=4: