FTPType

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

Syntax

FTPType (socket,filetypeReturns 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.

FTPType specifies the type of data transfer used by FTPGet and FTPPut, as ASCII or binary. In ASCII mode, line separators and other text formatting characters will be changed to the characters required by the local or remote system. In binary mode, line separators and other text formatting characters are not changed. If the information to be transferred is not text, use FTPType to change the transfer mode to binary. Otherwise, binary files such as archives, images, Omnis Libraries, and executable files may be corrupted by the processing of bytes that coincide with text-formatting characters.

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

FileType is a number indicating the type of subsequent FTPGet and FTPPut transfers on this socket.

Value Transfer Mode
kFalse/Zero ASCII
kTrue/One Binary

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 ascii
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
 # here we decide to put the download file into a folder called downloadFolder within the current Omnis tree
 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 downloading file ",
 upp(lRemoteFile)," to ",upp(lLocalFileName),
 kCr,"Error code : ",lErrCode)]}
 End If
End If