CScript Object Reference:TE Control

Contents
1. Overview
2. Properties
3. Functions
4.Events
5. TN3270 and TN5250 Controls

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

Back to Top

 


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
AutoLogin Boolean Login after connect.
Default = FALSE
BackspaceIsDelete Boolean Default = TRUE
Baud Integer Asynch communication baud rate.
Default = 9600
Blockmode Boolean Default = FALSE
CanAbort Boolean Allow ^C interruption for some functions.
Default = FALSE
CaptureDevice String Device or file for data capture.
Default = capt#.fil
CaptureFlush Boolean Close capture file at end of data.
Default = FALSE
CaptureMode Integer 0 ASCII (default)
1 BINARY
2 CONTROL
3 MNEMONIC
CaptureOn Boolean Data capture setting.
Default = FALSE
CaptureOverwrite Boolean Overwrite existing capture file.
Default = FALSE (append)
CaptureType Integer 0 PRINT MANAGER
1 DEVICE
2 FILE (default)
3 SPOOL
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
ChiseledLineDraw Boolean Use thin graphical line draw. Supersedes SolidLineDraw.
Default = FALSE
ChiseledSelection Boolean Indented text selection.
Default = FALSE
CommLink String Name of COMM object to load.
Default = COMM.COM
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 Backspace blanks out Characters.
Default = FALSE
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
0 ADM1
1 ANSI
2 AT386
3 IBM 3101
4 PCTERM
5 SCOANSI (Default)
6 TTY
7 TV912
8 TV925
9 TV950
10 VT100
11 VT102
12 VT220
13 VT220-7
14 VT320
15 VT320-7
16 WYSE50
17 WYSE60
18 WYSE60-25
19 IBM 3151
20 IBM 3151-25

TN5250 Modes
21 IBM3179-2
22 IBM3477-FT

TN3270 Modes
23 IBM3278-2
24 IBM3278-3
25 IBM3278-4
26 IBM3278-5
UNIX Modes
0
1 VT320
2 VT320-7
3 VT220
4 VT220-7
5 VT100/VT102
6
7 ANSI
8 AT386
9 SCOANSI
10 WYSE60
11 WYSE60-25
12 PCTERM
13 TV950
14 WYSE50
15 TV925
16 TV912
17 ADM1
18 IBM 3101
19 IBM 3151
20 IBM 3151-25
21 TTY

21 IBM3179-2
22 IBM3477-FT

23 IBM3278-2
24 IBM3278-3
25 IBM3278-4
26 IBM3278-5
ESCPassThru Boolean Telnet ESC pass-through.
Default = FALSE
Fingerprint String Current SSH fingerprint.
HasSSH Boolean True if current session is SSH. Read-only.
IgnoreHostColor Boolean Disables processing of sequences sent from host.
Default = FALSE
IgnorePrintStop Boolean Pause printing until PrintStopFlags condition is met.
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
KeyMacroPse Boolean Pause the Keyboard Macro Recorder.
Default = FALSE
LastError Integer Number of the last error. Read-only.
LDelay Integer Milliseconds of pause after a linefeed.
Default = 0
LoginString String String that controls auto login
LogoffString String String that controls auto logout.
MaskParity Boolean Enables stripping of the high bit from incoming data.
Default = FALSE
NetPort Integer Sets the TCP/IP port for Rlogin, Telnet or SSH connections.
Defaults
Telnet 23
Rlogin 513
SSH 22
Node String Specifies hostname, IP address, or phone number for Telnet, Rlogin, or TAPI connections
NoScroll Boolean Controls scrolling.
Default = FALSE
NumColumns Integer 1-132. Default = 80
NumLines Integer 1-66. Default = 25
NumLockON Boolean Default = FALSE
Pages Integer Number of screen pages, 1-6.
Default = 6
Parity Integer Asynch parity
0 None (Default)
1 Odd
2 Even
3 Mark
4 Space
Password String Password for auto-login
PrinterColumns Integer Number of columns on a printed page.
Default = 0 (auto set)
PrinterFile String File or device for printing.
PrinterFlags Integer For printing to file.
0 Append (default)
1 Overwrite
PrinterFlush Boolean Flush print buffer at end of job.
Default = FALSE
PrinterLines Integer Number of lines on a printed page.
Default = 0 (auto set)
PrinterMode Integer Determines printer setup
17 Print to file
18 Direct to device
19 Ignore print requests
20 To Windows printer
Add 32 to the number above to bypass the Windows printer driver. (Only affects setting 20.) Add 128 to add a form feed to the end of the print job. (Does not affect settings 17 or 19.)
PrinterPause Integer Number of seconds with no new data to wait before printing.
Default = 5
PrintStopFlags Integer 1 Print on key press
2 Print on timeout
ProxyHostID String Hostname or IP address of the proxy server.
ProxyPassword String Password for a proxy connection.
ProxyPort Integer TCP/IP port number for a proxy connection.
Proxytn_gw_nav Boolean Sets tn_gw_nav for proxy connections.
Default = FALSE
ProxyType Integer 0 None
1 Generic
2 SOCKS 4
3 SOCKS 5, no authentication
4 SOCKS 5, username & password
ProxyUserID String Username for a proxy connection.
RTS Boolean RTS/CTS flow control.
Default = FALSE
ScrollBack Integer Number of lines to store in the scrollback buffer.
Default = 999
ScrollBar Boolean Enables scrollbar.
Default = FALSE
ShowTelnet Boolean Show telnet negotiation.
Default = FALSE
SolidLineDraw Boolean Use thick graphical line draw. Superseded by ChiseledLineDraw.
Default = FALSE
SSHCompressionLevel Integer A number from 0 (none) to 9 (highest, default)
SSHCypherType Integer 0 None
1 DES
2 3DES (default)
3Blowfish
StopBits Integer Stop bits for asynch communication.
Default = 1
TabEx Boolean Expand tabs.
Default = TRUE
TDelay Integer Milliseconds of pause after a tab character.
Default = 0
TermID String VT ID of Terminal
TurnCharacter Integer ASCII value of IBM turnaround character.
Default = 13
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
WaitForCall Boolean Waits for an incoming call on the modem.
Default = FALSE
WindowsLookandFeel Boolean Enables Windows Look and Feel mode, a combination of ChiseledSelection and ChiseledLineDraw.
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.
Default = 5
XonCom Boolean XON/XOFF flow control.
Default = FALSE

Back to Top

 


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 Break
Break()
Send a Break signal to the host.

te.Break();

Void CancelDialog
CancelDialog()
Cancel a currently running dialog string.

te.CancelDialog();

Boolean Capture
Capture(nType,sFile)
Starts data capture of type nType (as CaptureType above) to file or device sFile. Returns 0 on successful capture start.

te.Capture(2,”C:\\capt#.fil”);

String Chrdy
Chrdy()
Returns the character pressed at the keyboard as a string, without waiting. If no key was hit, returns a zero-length string.

letter = te.Chrdy();

String Chrin
Chrin()
Waits for a character to be pressed at the keyboard and returns it as a string

letter = te.Chrin();

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

te.Cls();

String ComIn
ComIn()
Looks for a character to be received at the communications line and returns it as a string. If no character is received, returns a zero-length string

ltr = te.ComIn();

Boolean ComSt
ComSt()
Returns true if a character is received at the communications line

code = te.ComSt ();

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 returnimmediately (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 text format. 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);

String Cread
Cread(iTimeout,iChars,bOption)
Reads characters from the communications line into a string variable. Writes to the variable after nChars characters are received, or after nTimeout seconds have passed. If nTimeout is 0, it will not time out.

Option
0 No processing
1 Process incoming text through te.Trans()

msg = te.Cread(0,15,0);

Integer CreadInt
CreadInt(iTimeout,iChars,bOption)
Reads characters from the communications line into an integer variable. Acts as Cread() in all other respects
count = te.Creadint(0,15,0);

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);

Void Flush
Flush()
Flush the communications buffer
te.Flush();

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);

String GetFont
GetFont(iIndex)
Return the name, width in pixels and height in pixels of the font loaded in zero-based position iIndex.
font2 = te.GetFont(1);

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 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 IsClipboardEmpty
IsClipboardEmpty()
Returns true if nothing is stored in the clipboard
check = te.IsClipboardEmpty();

Integer KeyIn
Keyin()
Returns the number of the key pressed
keynum = te.KeyIn();

Void KeyMacroEnd
KeyMacroEnd()
Stops the Keyboard Macro Recorder
te.KeyMacroEnd();

String KeyMacroRec
KeyMacroRec(sFile)
Starts the Keyboard Macro Recorder and stores the results in the file specified by iFile. If iFile includes the # symbol, that will be replaced by a two-digit number. Returns the filename used

macrofile = te.KeyMacroRec(“macro#.cs”);

Boolean LoadKeyboard
LoadKeyboard(sKeyFile,sLayout)
Load keyboard layout sLayout from the .dat file specified by sKeyFile
te.LoadKeyboard("keyboard.dat","English");

Void MouseFunction
MouseFunction(iButton,iFunction,sMouseString)
Program mouse button iButton to perform iFunction using sMouseString. Valid mouse strings are listed in the TinyTERM Help file

Button
0 Left
1 Middle
2 Right

Function
0 Disable
1 Select
2 Send custom string

te.MouseFunction(1,2,”%o”);

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();

Void RevDim
RevDim(bOnoff)
Determines whether Wyse60 reverse fields are displayed as dim.
te.RevDim(1);

Integer SetAltCP
SetAltCP(sDatafile,sCodepage,iAltpagenum)
Sets the code pages for the SCOANSI alternate character set. iAltpagenum can be 1 or 2. Returns 0 for success.
te.SetAltCP("C:\\Program Files\\Century\\TinyTERM\\codepage.dat",”STD 437 MS-DOS Latin US”,2);

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 SetDECMNCP
SetDECMNCP(sDATFile,sCodePage)
Load VT220/VT320 multinational codepage sCodePage from .dat file sDATFile
mode = te.SetDECMNCP(CPfile,"1252");

Boolean SetDECSGCP
SetDECSGCP(sDATFile,sCodePage)
Load VT220/VT320 special graphics codepage sCodePage from .dat file sDATFile
mode = te.SetDECGSCP(CPfile,"1252");

Void SetDTRExit
SetDTRExit(bNewValue)
Drop DTR on exit
te.SetDTRExit(true);

Boolean SetEmInCP
SetEmOutCP(sDATFile,sCodePage)
Load receive codepage sCodePage from .dat file sDATFile
mode = te.SetEmInCP(CPfile,"1252");

Boolean SetEmOutCP
SetEmOutCP(sDATFile,sCodePage)
Load transmit codepage sCodePage from .dat file sDATFile
mode = 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");

Boolean SetKbdCP
SetKbdtCP(sDATFile,sCodePage)
Load keyboard codepage sCodePage from .dat file sDATFile
mode = te.SetKbdCP(CPfile,"1252");

Void SetKey
SetKey(iKey,iType,sValue)

Set key number iKey using mode iMode to send sValue. iMode should always be set to –1. To send a script command, add to the beginning of the string
te.SetKey(609,-1,"te.displaynl(“Hello there!”);”);

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 SetVT100SGCP
SetEmOutCP(sDATFile,sCodePage)
Load VT100 special graphics codepage sCodePage from .dat file sDATFile
mode = te.SetVT100SGCP(CPfile,"1252");

Boolean StopPrint
StopPrint()
Cancel a print job or print capture.
te.StopPrint();

Void Terminal Terminal(sString)
Pause script execution until sString is received from host, or until the user types Ctrl-E.
te.Terminal(“$$$”);

Void Trans
Trans(iType,iSource,iDest)
Translate a specified character received or transmitted to a different character value. iSource is the ASCII value of the character to translate, and iDest is the ASCII value of the resulting character
te.Trans(1,65,97);

Integer Wait
Wait(sString,iTimeout)

Wait iTimeout seconds for string sString to be received from the commline, or for the user to cancel by typing Ctrl-C. If iTimeout is set to 0, Wait will not time out. Returns 0 on success, -1 for a timeout, and -2 for a user cancel.
success = te.Wait("word: ",5);

Multiple match strings may be specified by separating them with the characters “^S|^S”. If this is done, the return value will be the zero-based position of the matched string. For example,

ret_val = te.Wait("word^S|^Sclient",5);

will return 0 if “word” is received, and 1 if “client” is received.

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);

Back to Top

 


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.

EBinaryMode()
This event fires when the emulator is set to binary mode.

ECapsLockOff()
This event fires when Caps Lock is turned off.

ECapsLockOn()
This event fires when Caps Lock is turned on.

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.

ENumLockOff()
This event fires when Num Lock is turned off.

ENumLockOn()
This event fires when Num Lock is turned on.

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.

Back to Top

 


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.