From wiki.visual-prolog.com

Revision as of 17:00, 19 February 2019 by Thomas Linder Puls (talk | contribs) (clarify)

For downloading, there is a Windows API called URLDownloadToFile which can do the job. This API needs urlmon.dll which is present in all Windows versions.

In your program, add the lines:

class predicates
    urlDownloadToFile : (unsigned, string URL, string File, unsigned Reserved, unsigned Callback) -> unsigned Hresult
        language apicall as "URLDownloadToFile".
class predicates
    doDownload : (string SourceURL, string Destfile).
    doDownload(SourceURL, Destfile) :-
        Hresult = uRLDownloadToFile(0, SourceURL, Destfile, 0, 0),
        if winErrors::s_ok <> Hresult then
            exception::raise_nativeCallException("URLDownloadToFile", Hresult,
                [namedValue("SourceURL", string(SourceURL)), namedValue("Destfile", string(Destfile))])
        end if.