The events listed in the TinyTERM version 4 CScript documentation can be handled by overloading the event handler functions. These functions often contain code that is neccessary to handle the event properly within TinyTERM, and this code must not be changed. You should only add additional code that you wish to execute when these events fire.
For example, if you would like to display a dialog when the user disconnects from the server that gives the user the option of reconnecting to the server or closing TinyTERM, you could use the following script :
/////////////////////////////////////
//
// Reconnect.cs
//
// This function displays a message when the user disconnects from the server
// and allows them to reconnect to the server by clicking the OK button
// in the message box.
//
// Written 7/17/03 by Jeremy Wolfe
//
/////////////////////////////////////////////
var nResponse;
var szTitle;
var szMsg;
szTitle = “Disconnected…”;
szMsg = “Click OK to Connect\rClick Cancel to Exit TinyTERM”;
// called when the session is closed
function
Reconnect()
{
nResponse = msgbox(szMsg, szTitle, 1);
if(nResponse == 0)
{
te.connect();
}else
{
quit();
}
}
function
TE_EDisconnect(DlgObj, CtlObj, nCode)
{
DisConnected(FindSessionByTE(CtlObj));
Reconnect();
}
The following is a list of the event handler functions :
TE_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.
function
TE_EExit()
{
File_Exit();
}
TE_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.
function
TE_EDisconnect(DlgObj, CtlObj, nCode)
{
DisConnected(FindSessionByTE(CtlObj));
}
TE_EConnect()
This event fires when a connection has occurred successfully.function
TE_EConnect(DlgObj, CtlObj, nCode)
{
local nSess;
local tfile;
nSess = FindSessionByTE(CtlObj);
Connected(nSess);
tfile = field(TESESS[nSess][556], _val(TESESS[nSess][438]) +1, _asc("|"));
if( exists( tfile) && _val(TESESS[nSess][438]) != -1) {
dprintln("Compile and Run Post Session Connect = ",tfile);
script_run(tfile);
}
script_sessconnect();
}
TE_EPrint(bON)
This event fires when printing commences or stops. bON is set to TRUE when printing starts, and FALSE when printing ends.
function
TE_EPrint(DlgObj, CtlObj, nCode, bOn)
{
local nSess;
nSess = FindSessionByTE(CtlObj);
if(bOn)
TESESS[nSess][dPRINTICON] = "1";
else
TESESS[nSess][dPRINTICON] = "0";
SessionIcons_Draw(); // draw Session Icons
dprintln("TE_Print Sess # = ", nSess, " OnOff = ",bOn);
}
TE_ENumLockOn()
This event fires when Num Lock is turned on.
function
TE_ENumLockOn()
{
dprintln("***ENumLockOn");
FrameStatBar.SetText(4,"NUM",SEBT_FLAT);
}
TE_ENumLockOff()
This event fires when Num Lock is turned off.
function
TE_ENumLockOff()
{
dprintln("***ENumLockOff");
FrameStatBar.SetText(4," ",SEBT_FLAT);
}
TE_ECapsLockOn()
This event fires when Caps Lock is turned on.
function
TE_ECapsLockOn()
{
dprintln("***ECapsLockOn");
FrameStatBar.SetText(3,"CAPS",SEBT_FLAT);
}
TE_ECapsLockOff()
This event fires when Caps Lock is turned off.
function
TE_ECapsLockOff()
{
dprintln("***ECapsLockOff");
FrameStatBar.SetText(3," ",SEBT_FLAT);
}
TE_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.
function
TE_ECapture(oParent,oTE,nCode,bCaptureOn,nCaptureType, sToolTip )
{
local nSession;
nSession = FindSessionByTE(oTE);
if(bCaptureOn)
TESESS[nSession][dCAPTICON] = "1";
else
TESESS[nSession][dCAPTICON] = "0";
if(Props[dTEObj] == TESESS[nSession][dTEObj])
Props[dCAPTICON] = TESESS[nSession][dCAPTICON];
if(nSession != nil)
SessionIcons_Draw(); // draw Session Icons
}
TE_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.
function
TE_ENextSession(oParent,oTE,nCode)
{
local nSession;
nSession = FindSessionByTE(oTE);
if(nSession != nil) {
if(nSession == TOTSESS-1) {
SwitchSess(0,1);
}
SwitchSess(nSession+1,0);
}
}
TE_EMouseDown(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.
function
TE_EMouseDown(oParent,oTE,nCode,nButton,nFlags,x,y)
{
var ret;
var nCode;
var pmenu;
dprintln("TE_EMouseDown ",nButton, " ",nFlags," ",x," ",y);
if(gTTType == "WC" && nButton == 2) {
dprintln("turning on menu");
if(CSESS[dCONNECT] == "1" || CSESS[dCONNECT] == "3")
pmenu = ResLoadMenu("#401");
else
pmenu = ResLoadMenu("#400");
nCode = TrackPopupMenu(GetSubMenu(pmenu, 0), 0, x, y, Frame);
DestroyMenu(pmenu);
dprintln("ret from pop up menu =%d\n", nCode);
TE_Frame_Command(oParent,oTE,nCode,nCode);
}
}
TE_EMouseUp(iButton,iShift,x,y)
This event fires when a mouse button is released in the control. The arguments are identical to those for MouseDown.
function
TE_EMouseUp(oParent,oTE,nCode,nButton,nFlags,x,y)
{
dprintln("TE_EMouseUp ",nButton, " ",nFlags," ",x," ",y);
}
TE_ELoginStart()
This event fires just before a login or logout scheme is performed.
function
TE_ELoginStart(DlgObj,nMsg,nCode )
{
local tfile;
var nSess = FindSessionByTE(nMsg);
if(nSess == -1)
nSess = 0;
// Activate on start of Logout
if(TESESS[nSess][dLOGINOUTFLAG] == "1") {
tfile = field(TESESS[nSess][434], _val(TESESS[nSess][440]) +1, _asc("|"));
if( exists( tfile) && _val(TESESS[nSess][440]) != -1) {
dprintln("Compile and Run Logout File = ",tfile);
script_run(tfile);
}
if(script_logout()) // Non Zero Return Cancel
nMsg.canceldialog();
TESESS[nSess][dLOGINOUTFLAG] == "0";
}
}
TE_ELoginStop()
This event fires just after a login or logout scheme has been performed.
function
TE_ELoginStop(DlgObj,nMsg,nCode)
{
local tfile;
var nSess = FindSessionByTE(nMsg);
if(nSess == -1)
nSess = 0;
// Activate on end of Login
if(TESESS[nSess][dLOGINOUTFLAG] == "0") {
tfile = field(TESESS[nSess][433], _val(TESESS[nSess][439]) +1, _asc("|"));
if( exists( tfile) && _val(TESESS[nSess][439]) != -1) {
dprintln("Compile and Run Login = ",tfile);
script_run(tfile);
}
script_login();
TESESS[nSess][dLOGINOUTFLAG] = "1";
}
}
This entry was posted
on Thursday, April 12th, 2007 at 1:51 pm and is filed under CScript.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.