CScript Object Reference:

FT Control

 

1 Overview

 

The FT object enables you to initiate and control file transfers from within a CScript script.

 

The following CScript demonstrates some of the FT Obect's features and how to use them. This script sends a file to a Unix host running the TERM UNIX product. Not that before running this script that you must already have connected to the host to which you want to transfer the file.

 

te.xmit( "term -1x\r" );    // put the host in server mode

ft = CreateFTObject();      // create a new FT object

ft.Protocol = "WTERMCRC";   // set the transfer protocol

ft.Mode = "b";              // use binary mode

ft.Commlink = te.Commlink;  // use the current connection

ft.Send( "file.txt", "." ); // send the file

DestroyObject( ft );        // delete the FT object

 

Note that this script sends the file without showing the user a file transfer progress dialog box.

 

 

2 Objects

 

Before using any file transfer script commands, the ft object must be created with the following command:

 

ft = CreateFTObject();

 

Properties may then be accessed using ft.ObjectName = argument, as in the following example. This command sets the email address to "user@isp.com":

 

ft.EmailAddress = "user@isp.com";

 

When all file transfer has been completed, the object must be destoyed:

 

DestroyObject(ft);

 

 

3 Properties

 

The following properties are used by the file transfer interface. Read-only properties are labeled as such:

 

Property Name   Data Type   Description

AddEOF          Boolean     Add end of file.

                            Default = FALSE

 

AltCheck        Boolean     Default = 0

 

AsciiLineDelay  Integer     Number of seconds between

                            transferring lines in

                            ASCII mode. Default=0

 

AsciiSendChar   Integer     ASCII line send

                            character. Default=13

 

BlockSize       Integer     Default = 4096

 

CommLink        String      String that specifies

                            the connection to use

                            for the file transfer.

                            This can be retrieved

                            from a connected TE

                            control. It is not

                            necessary to set this

                            for FTP connections

 

Compress        Boolean     Compression on.

                            Default = TRUE

 

Error           Integer     0 on success. Read-only

 

Esc8Bit         Boolean     Default = FALSE

 

EscControl      Boolean     Default = FALSE

 

ExternalGetString  String   External get string

 

ExternalXferString String   External transfer string

 

FileConversion  Boolean     Perform file conversion.

                            Default = FALSE

 

FileList        String      List of files sent or

                            received. Read-only

 

FinalStatus     String      "Success" or "Fail".

                            Read-only

 

Flags           Integer     Special flag used by some

                            protocols. Default = 0

 

HandshakeTimeout  Integer   Number of seconds for

                            handshake timeout.

                            Default = 30

 

HostName        String      Name of FTP host

 

IdleTime        Integer     Xon/Xoff idle time for

                            ASCII transfers.

                            Default = 0

 

KermitEcho      Boolean     Default = FALSE

 

KermitEOL       Integer     Kermit end of line

                            character.

                            Default = 13

 

Mode            String      FTP binary (b) or ascii

                            (a) mode. Default="b"

 

Password        String      Password for user account

                            on host

 

Progress        Integer     0-100 as a percentage of

                            completion. Read-only

 

Protocol        String      File transfer protocol.

                            Default = ""

                            TERMCRC

                            WTERMCRC

                            FTP

                            XMODEM

                            XMODEM-CR

                            YMODEM

                            ZMODEM

                            KERMIT

                            ASCII

                            LINE

 

RcvTimeout      Integer     Seconds for packet

                            receive timeout.

                            Default = 30

 

ReceiveSync     Boolean     Default = FALSE

 

RemoteDir       String      Destination directory.

                            Read-only

 

Restart         Boolean     Automatically restart on

                            failure. Default = TRUE

 

Retries         Integer     Number of times to

                            restart the file

                            transfer. Default = 3

 

SendTimeout     Integer     Seconds for packet send

                            timeout. Default = 30

 

Separator       String      String that separates

                            each filename.

                            Default = ";"

 

TapFile         String      Fully qualified .tap file

                            name

 

ToUpper         Boolean     Convert filenames to

                            upper case.

                            Default = FALSE

 

UserName        String      Name of user account on

                            host

 

WindowPacketSize  Integer   Default = 4096

 

 

4 Functions

 

Void Close

Close()

Uses the "Protocol" property to determine which protocol object to close. If the "Protocol" property is NULL or "", all objects are closed

ft.Close();

 

Integer GetError

GetError()

Result code of the last Send or Receive

errcode = ft.GetError();

 

String GetFileList

GetFileList()

Returns the FileList string passed as part of the last Send or Receive

files = ft.GetFileList();

 

Integer GetProgress

GetProgress()

Returns the current progress percentage 0-100

percent = ft.GetProgress();

 

String GetRemoteDir

GetRemoteDir()

Returns the RemoteDir string passed as part of the last Send or Receive

dest = ft.GetRemoteDir();

 

String GetStatus

GetStatus()

Returns the current status string - "Success", "Fail", or "Pending"

stat = ft.GetStatus();

 

Void Receive

Receive(sRcvParm)

Receives files listed in sRcvParm, or if sRcvParm specifies a directory, files from that directory on the remote host

ft.Receive("Customers.doc");

 

Void Send

Send(sSendParm, sDest)

Sends files listed in sSendParm, or files in directory specified by sSendParm to destination specified by sDest

ft.Send("C:\\Outfiles",".");

 

Void SetUpdateWindow

SetUpdateWindow(oForm)

Sets form to update with transfer status

ft.SetUpdateWindow(FTStatus);

 

Integer ShowStatusString

ShowStatusString(iStatusCode)

Shows a modal dialog box with completion text for the iStatusCode value

ft.ShowStatusString(1);

 

 

5 Events

 

EndBatchReceive()

This event is fired at the end of the Receive method

 

EndBatchSend()

This event is fired at the end of a Send method

 

StartBatchReceive()

This event is sent at the beginning of Receive method

 

StartBatchSend()

This event is sent at the beginning of Send method

 

 

6 Protocols

 

6.1 FTP Protocol

The FTP protocol uses the following properties:

 

Property        Comments

Mode            Must be set prior to a Send or Receive   

Protocol        Must be set prior to a Send or Receive.

                Upper and lower case are both accepted.

                Internally the string value is converted

                to an integer protocol ID

 

UserName        Optional. If blank, "anonymous" will be

                Used

 

Password        Optional. If blank, username@domain will

                be used

 

HostName        Semi-Optional. If blank, the remote

                birectory passed to either Send or

                Receive must contain the HostName. For

                example, if HostName is blank, the

                RemoteDir parameter MUST be something

                like: www.sitename.com/incoming/rd

                or 10.12.51.11/incoming/rd