CScript Object Reference:

TE Control

 

 

1 Overview

 

TE functionality includes terminal emulation, communications relating to terminal emulation, host mode (server), and all properties and functions relating to the above capabilities. The TE control does not include any file-transfer components.

 

The following CScript demonstrates some of the TE Obect's features and how to use them. This script asks the user for the host name that the user wants to connect to, sets the necessary properties for a default Telnet connection, and connects to the host the user entered.

 

// get hostname from the user

var node = te.Read("Hostname: ", 1);

 

// set TE properties and connect

te.Node = node;        // Sets node = "Hostname"

te.NetPort = 23;       // Default Telnet Port

te.ConnectionType = 0; // Telnet connection

te.Emulation = 5;      // Set emulation type to SCOANSI

te.AutoLogin = 0;      // Turns autologin off  

te.Connect();          // Connects to host

 

 

2 Properties

 

Object properties act as variables. To set the value of a property, use the format te.Property = argument. For example:

 

te.Emulation = 0;

 

To get the value of a property, use the property as the argument of an assignment or wherever you need the property's value. For example:

 

var sNode = te.Node;

 

Each TE object includes the following properties:

 

Property Name      Data Type      Description

AddCR              Boolean        Add CR to end of line.

                                  Default = FALSE

 

AddLF              Boolean        Add LF to end of line.

                                  Default = FALSE

 

AutoConnect        Boolean        Connect on session open.

                                  Default = FALSE

 

BackspaceIsDelete  Boolean        Default = TRUE

 

Baud               Integer        Asynch communication baud

                                  rate. Default = 9600

 

Blockmode          Boolean        Default = FALSE

 

CanAbort           Boolean        Allow ^C interruption for

                                  a number of functions.

                                  Default = FALSE   

 

CaptureON          Boolean        Data capture setting.

                                  Default = FALSE

 

CharSet            Integer         0    American (Default)

                                   1    British

                                   2    Dutch

                                   3    Finnish

                                   4    French

                                   5    Canadian

                                   6    German

                                   7    Italian

                                   8    Danish

                                   9    Norwegian

                                  10    Portugese

                                  11    Spanish

                                  12    Swedish

                                  13    Swiss

 

CommLink           String         Magic string for getting

                                  and setting a connection

 

ComPort            Integer        Sets the COM port used

                                  for asynchronous

                                  communications by number

 

ConnectionType     Integer         0    Telnet (Default)

                                   1    Rlogin

                                   2    Asynchronous   

                                   3    TAPI

 

CursorType         Integer        0    Blinking Block (Default)

                                  1    Solid Block

                                  2    Blinking Line

                                  3    Solid Line   

 

DestructiveBackspace    Boolean   Default = TRUE

 

DisconnectOnExit   Boolean        Default = TRUE

 

DropDTROnExit      Boolean        Default = TRUE

 

DuplexMode         Integer        0    Full (Default)

                                  1    Half

                                  2    Mnemonic

                                  3    Control   

 

Emulation          Integer

    Note that the value you use to set the emulation mode

    and the value you get when you get the emulation do not

    correspond.

 

          Set Value                     Get Value

    ----------------------      --------------------------

    UNIX Modes                  UNIX Modes

     0    ADM1                     0   

     1    ANSI                     1    VT320   

     2    AT386                    2    VT320-7

     3    IBM 3101                 3    VT220

     4    PCTERM                   4    VT220-7

     5    SCOANSI (Default)        5    VT100/VT102

     6    TTY                      6   

     7    TV912                    7    ANSI

     8    TV925                    8    AT386

     9    TV950                    9    SCOANSI

    10    VT100                   10    WYSE60

    11    VT102                   11    WYSE60-25

    12    VT220                   12    PCTERM

    13    VT220-7                 13    TV950

    14    VT320                   14    WYSE50

    15    VT320-7                 15    TV925

    16    WYSE50                  16    TV912

    17    WYSE60                  17    ADM1

    18    WYSE60-25               18    IBM 3101

    19    IBM 3151                19    IBM 3151

    20    IBM 3151-25             20    IBM 3151-25

                                  21      TTY

 

    TN5250 Modes

       21    IBM3179-2            21    IBM3179-2

       22    IBM3477-FT           22    IBM3477-FT

 

    TN3270 Modes

       23    IBM3278-2            23    IBM3278-2

       24    IBM3278-3            24    IBM3278-3

       25    IBM3278-4            25    IBM3278-4

       26    IBM3278-5            26    IBM3278-5

 

Extend             Boolean        Default = TRUE

 

IgnoreHostColor    Boolean        If TRUE, disables processing

                                  of color sequences sent from

                                  host. Default = FALSE   

 

IsConnected        Boolean        TRUE if a connection is

                                  active. Read-only

 

JumpScroll         Integer        Number of lines to jump

                                  scroll. Set to 0

                                 (default) to turn off

 

LastError          Integer        Number of the last

                                  error. Read-only

 

MaskParity         Boolean        Enables stripping of the

                                  high bit from incoming

                                  data. Default = FALSE   

 

NetPort            Integer        Sets the TCP/IP port used

                                  for Rlogin and Telnet

                                  connections. Default = 23

 

Node               String         Specifies hostname, IP

                                  address, or phone number

                                  for Telnet, Rlogin, or

                                  TAPI connections

 

NumColumns         Integer        1-132. Default = 80

 

NumLines           Integer        1-66. Default = 25

 

NumLockON          Boolean        Default = FALSE

 

Overwrite          Boolean        Default = FALSE

                                  True overwrites the old

                                  capture file.

 

Pages              Integer        Number of screen pages,

                                  0-7. Default = 7

 

Parity             Integer        Asynch parity

                                   0    None (Default)

                                   1    Odd

                                   2    Even

                                   3    Mark

                                   4    Space

 

Password           String         Password for auto-login

 

ScrollBack         Integer        Number of lines to store

                                  in the scrollback buffer.

                                  Set to 0 to turn off

                                  scrollback.

                                  Default = 999

 

ScrollBar          Boolean        Enables scrollbar.

                                  Default = FALSE

 

StopBits           Integer        Stop bits for asynch

                                  communication.

                                  Default = 1

 

TabEx              Boolean        Expand tabs.

                                  Default = TRUE

 

TDelay             Integer        Seconds of pause between

                                  typed characters.

                                  Default = 0

 

TermID             String         VT ID of Terminal

 

TurnCharacter      Integer        ASCII value of IBM

                                  turnaround character.

                                  Default = 7

 

UseAlt             Boolean        Enables handling of ALT

                                  keys in emulators.

                                  Default = FALSE

 

UserName           String         User name for auto-login

 

ViewLogin          Boolean        View auto-login process.

                                  Default = FALSE

 

WindowsLookandFeel Boolean        Enables Windows Look and

                                  Feel mode, a combination

                                  of indented selection and

                                  chiseled line draw

                                  characters.

                                  Default = FALSE

 

WordLength        Integer         Asynch communication word

                                  length. Default = 8

 

WrapLines         Boolean         Wrap long lines.

                                  Default = TRUE

 

WRU               String          String sent after WRUChar

                                  is received

 

WRUChar           Integer         ASCII value of character

                                  to request WRU string

 

 

3 Functions

 

TE objects are accessed in scripting with the format te.ObjectName(parameters). For example, to clear the screen, the command is:

 

te.cls();

 

Integer AddFont

AddFont(sFontName,sCodePage,iFontIndex)

Add a font to the font list in the TE control. sCodePage is limited to the short name of the code page. The code page file is now hardcoded to be tcs.dat. iFontIndex runs from 0-(MAXFONTS-1), where MAXFONTS is currently set to 4, and is a compile-time #define. Passing -1 to iFontIndex will load the font in the next available slot. Returns -1 on failure, and the index where the font was loaded on success

index = te.AddFont("Arial","1252",-1);

 

Void CancelDialog

CancelDialog()

Cancel a currently running dialog string

te.CancelDialog();

 

Integer Cls

Cls()

This function will clear the terminal emulator screen, as well as the scrollback buffer. Always returns 0

te.Cls();

 

Integer Connect

Connect()

Attempts to make a connection to a remote server, using the parameters set earlier. If this method succeeds (indicated by the return code) an EConnect (for a successful connection) or an EDisconnect (for a failed connection) event will eventually be fired. The success of this function merely indicates that a connection is in progress, not that we are actually connected with the remote server. For instance, a TELNET connection to a remote machine will return immediately (assuming that all the parameters are set correctly), but the connection is not actually established until the EConnect is received. On failure of the connection, EDisconnect will be fired. Returns 0 for success, non-zero for various failure modes, depending upon the type of failed connection

mode = te.Connect();

 

Void CopySelection

CopySelection(x,y,w,h)

Copy a portion of the emulator screen to the clipboard in both text and bitmap formats. The top left corner of the emulator is x=1 and y=1. If all parameters are 0, copies the currently selected portion of the emulator screen to the clipboard. If all parameters are -1, the entire emulator screen will be copied

te.CopySelection(2,1,15,1);

 

Boolean DeleteFont

DeleteFont(iFontIndex)

Remove a font entry from the font table. As the font list in TE is not a sparse array, the font list is compacted, and the fonts above the index to be deleted (if any) are moved down, decrementing their index values

te.DeleteFont(2);

 

Boolean Disconnect

Disconnect()

Disconnect from the current connection. If this function succeeds, an EDisconnect event will be fired. Disconnecting when there is no current connection is considered a failure

te.Disconnect();

 

Void Display

Display(sDisplay)

Output the given string on the terminal emulator display at the current cursor position, without sending it to the CommLink or appending a newline

te.Display("Hello world");

 

Void DisplayNL

DisplayNL(sDisplay)

Output the given string on the terminal emulator display at the current cursor position and append a newline

te.DisplayNL("Hello world");

 

Integer DoDialog

DoDialog(sString)

Execute a dialog string. Returns 0 on success, -1 for a timeout, and -2 for a user cancel

dcode = te.DoDialog(instr);

 

Integer GetBGColor

GetBGColor(iAttr)

Return the current background color of text attribute iAttr

 

Attribute

=========

 0 Normal

 1 Reverse

 2 Blink

 3 Underline

 4 Bold

 5 Reverse Blink

 6 Reverse Underline

 7 Reverse Bold

 8 Blink Underline

 9 Blink Bold

10 Underline Bold

11 Reverse Blink Underline

12 Reverse Blink Bold

13 Reverse Underline Bold

14 Blink Underline Bold

15 Reverse Blink Underline Bold

 

Color

=====

 0 Default, based on Normal attribute

 1 Black

 2 Blue

 3 Green

 4 Cyan

 5 Red

 6 Magenta

 7 Brown

 8 White

 

BGcolnum = te.GetBGColor(0);

 

Integer GetFGColor

GetFGColor(iAttr)

Return the current foreground color of text attribute iAttr

 

Color

=====

 0 Default, based on iAttr 0

 1 Black

 2 Blue

 3 Green

 4 Cyan

 5 Red

 6 Magenta

 7 Brown

 8 White

 9 Light Gray

10 Light Blue

11 Light Green

12 Light Cyan

13 Light Red

14 Light Magenta

15 Yellow

16 Light White

 

FGcolnum = te.GetFGColor(0);

 

Integer GetRGBEntry

GetRGBEntry(iEntry)

Return the current RGB value from the index specified by iEntry from the RGBMap

color = te.GetRGBEntry(ccode);

 

String GetSelection

GetSelection(x,y,w,h,iType)

Copy a portion of the emulator screen and return it. The x, y, w, h parameters behave exactly like CopySelection. Only iType 0 is currently supported, meaning that only strings will be returned

appname = te.GetSelection(2,1,15,1,0);

 

Integer GetTextAttribute

GetTextAttribute(iAttr)

Returns a bitfield indicating which characteristics are applied to text attribute iAttr. The bitfield will be a sum of the following:

 

Characteristic

==============

 1 Bold

 2 Underline

 4 Blink

 8 High bright

16 Low bright

 

applied = te.GetTextAttribute(0);

 

Boolean LoadKeyboard

LoadKeyboard(sKeyFile,sLayout)

Load keyboard layout sLayout from the .dat file specified by sKeyFile

te.LoadKeyboard("keyboard.dat","English");

 

Void Paste

Paste(iType)

Paste the contents of the clipboard into the emulator. iType 0 means to paste text, and 1 is link format. The data pasted is not processed by the keyboard code pages, but rather is sent out the comm line (if any) without additional processing except for carriage return/line feed corrections and duplex settings

te.Paste(0);

 

Void PrintScreen

PrintScreen()

Print the current emulator screen

te.PrintScreen();

 

Void PrintSetup

PrintSetup(hWndParent)

Display the page setup dialog to allow customization of the print settings

te.PrintSetup();

 

String Read

Read(sDisplay,bEcho)

Display prompt sDisplay and wait for user input, returning the string the user entered once RETURN (or ^C if CanAbort is set) is pressed. Characters entered by the user are not sent on the CommLink, but are echoed to the emulator display if bEcho is set to TRUE

uname = te.Read("Enter username: ",false);

 

Void Redraw

Redraw()

Redraws the emulator screen

te.Redraw();

 

Boolean SetBackgroundImage

SetBackgroundImage(sImage,iMethod)

Display background image sImage in the emulator window

 

iMethod

=====

0 Stretch image to fit the size of the terminal emulator

1 Tile image inside the terminal emulator

2 Center the image inside the terminal emulator

 

te.SetBackgroundImage("c:\\images\\walpapr.jpg",2);

 

Void SetBGColor

SetBGColor(iAttr,iColor)

Set background color for text attribute iAttr to color number iColor. Uses the same attribute and color numbers as GetBGColor

SetBGColor(4,7);

 

Boolean SetEmOutCP

SetEmOutCP(sDATFile,sCodePage)

Load codepage sCodePage from .dat file sDATFile

te.SetEmOutCP(CPfile,"1252");

 

Void SetFGColor

SetFGColor(iAttr,iColor)

Set foreground color for text attribute iAttr to color number iColor. Uses the same attribute and color numbers as GetFGColor

SetBGColor(4,11);

 

Boolean SetFontCP

SetFontCP(iFontIndex,sCPDataFile,sCodePage)

Select new code page sCodePage from file sCPDataFile for font iFontIndex

te.SetFontCP(2,CPfile,"1252");

 

Void SetRGBEntry

SetRGBEntry(iEntry,iRGBValue)

Modify entry number iEntry in the RGBMap

te.SetRGBEntry(2,newcolor);

 

Void SetTextAttribute

SetTextAttribute(iAttr,iChar)

Sets characteristics of text attribute iAttr according to bitfield iChar

te.SetTextAttribute(0,12);

 

Boolean StopPrint

Cancel a print job or print capture

te.StopPrint();

 

Integer Wait

Wait(sString,iTimeout)

Wait iTimeout seconds for string sString to be received from the commline. Returns 0 on success, -1 for a timeout, and -2 for a user cancel

success = te.Wait("word: ",5);

 

Integer Xmit

Xmit(sString)

Send string sString over the current connection. The string is not processed by the keyboard code page, but is processed with carriage-return/linefeed translations and duplex mode. Returns an integer representing the number of characters transmitted, or -1 on error

numchars = te.Xmit(uname);

 

 

4 Events

 

Click()

This event fires when a click is performed in the control.

 

DblClick()

This event fires when a double click is performed in the control.

 

ECapture(bON,iCaptureType,sDevice)

This event fires when a capture operation starts or stops. bON is TRUE when capture is being turned on, FALSE when it is being turned off. iCaptureType is the type of capture that is currently configured. sDevice is the device that is being used for capture.

 

EConnect()

This event fires when a connection has occurred successfully.

 

EDisconnect()

This event fires when a connection has terminated (either through user action or a remote disconnection; i.e., when a socket is disconnected). This event also fires when an attempted connection fails. You will not receive this event if a given TE control is destroyed before the connection is terminated.

 

EExit()

This event fires when the user has pressed ALT-F4. This can only happen when the UseAlt property is set to FALSE. This can be used by the application to shut down.

 

ELoginStart()

This event fires just before a login or logout scheme is performed.

 

ELoginStop()

This event fires just after a login or logout scheme has been performed.

 

ENextSession()

This event fires when the user has indicated (via a keystroke) that they want to advance to the next session. The actual switching of sessions must be handled by the application.

 

EPrint(bON)

The event fires when printing commences or stops. bON is set to TRUE when printing starts, and FALSE when printing ends.

 

MouseDown(iButton,iShift,x,y)

This event fires when a mouse button is depressed in the control. iButton is the number of the mouse button that is depressed. The left button is 1, the right button is 2, and the middle button is 4. iShift is the status of the shifting keys at the time of the keypress. iShift is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. iShift indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT were pressed, the value of iShift would be 6. x and y are the x and y positions of the mouse cursor, relative to the upper left hand corner of the control.

 

MouseUp(iButton,iShift,x,y)

This event fires when a mouse button is released in the control. The arguments are identical to those for MouseDown.

 

 

5 TN3270 and TN5250 Controls

 

The TN3270 and TN5250 controls provide emulations for these IBM terminal types. These controls support all the properties and methods of the TE control with the following additions and exceptions:

 

·         The TN3270 and TN5250 controls do not support the te.read method.