DOWNLOAD@

Platform

Win32, x64

Purpose

To to read the contents of a URL into memory.

Syntax

INTEGER(7) FUNCTION DOWNLOAD@(URL, FILESIZE, ERROR)
CHARACTER(*) URL
INTEGER FILESIZE, ERROR

Description

The function returns the INTEGER address of the downloaded file stored in memory. The memory can be released by a call to RETURN_STORAGE@.

FILESIZE is the size of the file that is to be downloaded. If this value is zero then the function returns zero and the size of the file is the returned as the new value of FILESIZE. The returned error code ERROR is zero for success. An error code value of 1 (one) indicates that FILESIZE was too small so that only part of the file was stored. Error code values greater than 1 (one) indicate total failure with the function returning a zero address.

The returned address can be used to access the file by using FTN95 intrinsics such as CCORE1(addr).

See also

READ_URL@ and download options, Linking to the web

Example

INCLUDE <clearwin.ins>
INTEGER err,fileSize
INTEGER(7)handle
CHARACTER(80) url
url = "http://..."
err = 0
fileSize = 0
handle = DOWNLOAD@(url, fileSize, err)
IF(err > 0) STOP 'Download failed'
fileSize = fileSize + 4
handle = DOWNLOAD@(url, fileSize, err)
!Display the first 20 characters in the download...
DO i=0,20 
 PRINT*, CCORE1(handle+i)
ENDDO
CALL RETURN_STORAGE@(handle)
. . .

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited