|
Summary
The OnSend event is fired during an event based put or append operation to get the next block of data.
Description
The OnSend event occurs during an event based transfer of data from the local machine to a remote file. An event driven put or append operation is started by calling the PutFile or AppendFile
method (or by setting the FileAction property to FILE_ACTION_PUT or FILE_ACTION_APPEND) with the call to the EventMode method (or the TransferMode property set to TRANSFER_MODE_EVENT). The remote
file must be specified with the RemoteFile parameter, but the LocalFile parameter is ignored and can be left blank.
With each event, the application is given a string buffer and an integer specifying the maximum number of bytes that can be copied into the string buffer. It is up to the application to obtain the
data. The data copied into this buffer could, for example, be read from a disk file, received from another application using DDE or copied from the clipboard. Although less than the requested number
of bytes can be assigned to the string buffer, it is generally preferable for performance reasons to copy the maximum number of bytes if they are available.
In some environments, such as Visual J++, the new value assigned to the Buffer parameter can not be successfully retrieved by the control. In these cases set UseProperty to True, and assign
data to the SendData property instead of the Buffer parameter. The UseProperty property must be set to True before the FileAction property is set to FILE_ACTION_PUT or FILE_ACTION_APPEND (or
before calling the PutFile or AppendFile method) In this case treat the SendData property exactly as you would the Buffer parameter. If UseProperty is True the Length parameter will
be ignored.
To indicate that no more data is available to send, the application should clear the string buffer by assigning an empty string ("") to it. After returning an empty string buffer, no more OnSend
events will be generated. The application can also terminate an event based transfer by setting the FileAction property to FILE_ACTION_ABORT (or by calling the AbortFile method can also be used)
during the OnSend event. In this case, the returned string buffer is ignored by the control.
While handling the OnSend event, an application should not perform tasks, which have the potential of requiring a lot of time to complete, such as generating a message box.
Example
Sub FTPClient_OnSend (Buffer As String, Length As Integer) Dim Message As String If Len(Message) > 0 Then
Buffer = Message ' send message Message = "" Else Buffer = Message ' indicate end of message End If
End Sub
Sub FTPSend
FTPClient.Eventmode()
FTPClient.PutFile ("test.txt")
' OnSend event fired to get data
EndSub
|