FTPGet

Command group Flag affected Reversible Execute on client Platform(s)
External commands YES NO NO All

Syntax

FTPGet (socket,remotefile,localfile[,filetype,creator]) Returns status

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This Web command is multi-threaded, allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.

FTPGet downloads a file from an FTP server. The file is transferred using the currently specified transfer type of ASCII or binary, as specified by the FTPType command. It is important that you set the transfer type correctly for each file you download, since an incorrect transfer type will result in a bad downloaded copy of the file.

Socket is an Omnis Long Integer field containing a socket opened to an FTP server using FTPConnect.

RemoteFile is an Omnis Character field containing the pathname of the remote file to download.

Note: The remote filename may not be acceptable to the local system.

LocalFile is an Omnis Character field containing the pathname of the downloaded file. If the file already exists, FTPGet will overwrite it with the downloaded file.

FileType and Creator are optional arguments, which the command uses on the Macintosh platforms only. These specify a file type and creator for the downloaded copy of the file. If you omit these arguments when calling FTPGet on a Macintosh, they default as follows:

Status is an Omnis Long Integer field which receives the result of executing the command. Possible error codes are listed in the Web Command Error Codes Appendix.

Example

# set file transfer mode to asci
FTPType (iFTPSocket,0) Returns lErrCode
If not(lErrCode)
  # assumes you are already in the correct folder on the ftp server so only the file name is needed
  Calculate lRemoteFile as 'myFileToDownload.txt'
  # identify where to download the file to
  Calculate lLocalFileName as con(sys(115),'downloadFolder',sys(9),lRemoteFile)
  # download the file
  FTPGet (iFTPSocket,lRemoteFile,lLocalFileNameReturns lErrCode
  If lErrCode
    OK message FTP Error {[con("Error transferring file ",upp(lRemoteFile)," to ",upp(lLocalFileName),kCr,"Error code : ",lErrCode)]}
  End If
End If