CScript Built In Function Reference

Contents
1. Overview
2. Document Conventions
3. Command Reference

1. Overview

The CScript scripting language provides a library of functions that enable you to interact with the operating system and includes utility functions to make developing scripts for the TinyTERM emulator easier. This document describes the commands available and how to use these built in functions.


2. Document Conventions

The CScript Builtin Function Reference describes commands using the following format:

Values passed to script functions are categorized by the first letter of their names. The category letters are all lower-case, and follow the convention listed below. The category names also apply to the values returned by the functions.

Category Name Implementation Code
Time 32-bit integer t
Integer 32-bit i
String 64k max length s
Floating point IEEE 64-bit f
Boolean 0/non-zero True/false b
Handle (Win32) 32-bit h
Object 32-bit o
Void No parameter or return value  
Variable Name String v

Back to Top

 


3. Command Reference

The following sections contain quick explanations of programming syntax, keywords, and commands for the built in functions available in the CScript language. These commands are organized into the following categories

Back to Top

 


3.1 Primitive Commands

Boolean AxRegisterEvent
AxRegisterEvent(oObject,str,str2)
Registers call back function
AxRegisterEvent(ft,"EndBatchReceive","ft_EndBatchReceive");

Object CreateObject
CreateObject( sObjName, sObjClass, iExStyle, iStyle, iX, iY, iW, iH, sTitle, iID, oParentObject )
Creates an object based on a Win32 window class

ObjFrame = CreateObject( "TE_Frame", "[FRAME]", 0, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, "TinyTERM", 0, 0 );

Void DestroyObject
DestroyObject(oObj)
Deletes and deallocates an object

DestroyObject(ft);

Integer RegisterFile
RegisterFile(sFile)
Registers an in-process COM server in DLL sFile. Returns 0 for success or -1 for failure

success = RegisterFile(“cencom32.dll”);

Void Dprintln
Dprintln(sArg0[[[,sArg1],sArg2],sArg3]...)
Prints to debug screen in debug mode

dprintln("Hello");

Back to Top

 


3.2 File I/O Commands

Boolean Chdir
Chdir( sPath )
Changes the current directory.
chdir( "C:\temp" );

Integer Copy
Copy(sSrcFile, sDestFile)
Copies one file to another. Returns 0 on success.

copy("default.tpx", "newtpx.tpx");

Integer Erase
Erase(sFile)
Erases file. Returns 0 on success.

erase("default.tpx");

Boolean Exists
Exists(sFileName)
Returns true if passed file exists

b = exists("d:\\century\\default.tpx");

Void Fclose
Fclose(iFileID)
Closes a file opened with Fcreate or Fopen

fclose(1);

String Fconcat
Fconcat(sPath,sFile,sExt)
Returns a full pathname from path, file and extension. Note: this function will automatically concatenate a "\" character to the end of sPath unless sPath ends with a "\" or contains a drive designation, such as "c:".

str = fconcat("c:\\century","default","tpx");

Boolean Fcreate
Fcreate(iFileID, sFile)
Creates a new file. Overwrites an existing file

fcreate(iFIleID, "default.tpx");

Boolean Feof
Feof(iFileID)
Returns true if at end of file

b = feof(fileno);

String Fext
Fext(sPathFile)
Returns extension from passed file string


Integer Fflush
Fflush(iFilenum)
Flushes the data for the file associated with iFilenum. If the file is open for output, this will write the contents of the buffer for the file to disk. If the stream is open for input, this will clear the contents of the buffer. Returns 0 for completion, 1306 if the file number is not in the range of 1 through 20, and 1303 if an I/O error occurred during the flush operation.

str = fext("c:\\century\\default.tpx");

String Fhead
Fhead(sNamePath)
Gets file head

fileh = fhead("d:\\century\\default.tpx");

Time Value FileDate
FileDate(sFileName)
Gets file date of filename as a time value

tim = filedate("default.tpx");

Integer FileMode
FileMode(sFileName)
Returns the mode settings for file sFileName. This is a 16-bit value returned from a stat call to the file. Possible values include:

Regular file 0x8000 (32768)
Directory 0x4000 (16384)
Character special 0x2000 (8192)
Pipe 0x1000 (4096)
Read permission 0x0100 (256)
Write permission 0x0080 (128)
Execute permission 0x0040 (64)

The returned value will be a sum of one or more of these settings.

mode = FileMode("default.tpx");

Integer FileSize
FileSize(sFileName)
Gets the size in bytes of a file. If the file does not exist, a 0 will be returned.

bytes = FileSize("default.tpx");

Integer Fopen Fopen( iFileID, sFile, sMode ) Opens a file sFile, sets the file ID for that file to iFileID, and opens the file read/write mode according to sMode.

  iMode
RA Read only, ASCII mode
RB Read only, Binary mode
WA Write to new file, ASCII mode (overwrites an existing file)
WB Write to new file, Binary mode (overwrites an existing file)
UA Append to an existing file, ASCII mode
UB Append to an existing file, Binary mode

Note that opening a text file with Unix-style line breaks in ASCII mode can lead to some unexpected behavior, including ftell() returning negative values and fseek() not moving the file pointer predictably. Use Binary mode for files with Unix-style line breaks.

fopen( 19, "default.tpx", "RB" );

String Fname
Fname(sNamePath)
Returns stripped filename only from passed full pathname

str = fname("d:\\century\\default.tpx");

String Fpath
Fpath(sNamePath)
Returns stripped path only from passed full path and filename
path = fpath("d:\\century\\default.tpx");

String Fread
Fread( iFileID, iByte )
Reads iByte bytes from file referred to by iFileID. If iByte = -1, reads to end of line or file, whichever comes first.
str = fread( 1, -1 );

String Freadln
Freadln( iFileID, iByte)
Reads a line from a file referred to by iFileID, either to end of line or a maximum of iByte bytes, whichever comes first.
str = freadln( 1, -1 );

Integer Fseek
Fseek(iFileID, iOffset, iOrigin)
Moves file pointer for file iFileID to location iOffset from the location set by iOrigin.

  iOrigin
0 Beginning of file
1 Current position
2 End of file

fseek(1,3,0);

Integer Ftell
Ftell(iFileID )
Gets the current position of the file pointer in the file refered to by iFileID.

nPosition = ftell( 2 );

Integer Fwrite
Fwrite( iFileID, sText, iByte )
Writes sText to file associated with iFileID, with iBytes maximum number of bytes written. If iBytes is negative, Fwrite writes the all of sText. Returns 0 for success, 1 if the file is not open, and 1300 for an I/O error writing to the file.

fwrite( 2, "Hello", -1 );

Integer Fwriteln
Fwriteln( iFileID, sText, iByte )
As Fwrite, but adds a carriage return/line feed pair to the end sText when writing.

fwrite( 2, "Hello", -1 );

String GetCommandLine
GetCommandLine( )
Gets the command line, including all parameters, used to launch this session of the TinyTERM emulator.

cmdline = GetCommandLine( );

String GetPath
GetPath(sFile,sType)
Gets the path of a file. sType can be "U" (user), "S" (system) or both. The first listed has precedence

path = GetPath("system.ini", "S");

VoidM IniDeleteSection
IniDeleteSection( sFile, sSection )
Deletes a section from an .ini file

IniDeleteSection( "user.ini", "keyboard" );

Void IniDelStr IniDelStr(sSection,sKeyName)
Deletes a key from an ini-format file

IniDelStr("colors","fgcolor");

String IniEnumSections
IniEnumSections(sFile1,sMatch )
Returns a "|" delimited list of all sections in the .ini file that match the pattern. (Note that the returned strings in the list have the matched suffixes removed.)

list = inienumsections( "log.dat", "*.login" );

String IniGetStr
IniGetStr(sSection,sKeyName,sDefault)
Gets data from an ini-format file. Returns default if key does not exist

str = inigetstr("log",key, " ");

String IniListKeys
IniListKeys(sFile,sSection)
List keys defined in an ini-format file

list = IniListKeys("tt.ini","section");

Void IniMerge
IniMerge(sSect,sFile,sSect2,sFile2)
Merges sSect from file sFile into sSect2 in sFile2.

inimerge("login","tt.ini","login","ftp.ini");

Void IniReplaceKeys
IniReplaceKeys(sFile,sSection,sList)
Replaces keys in an ini-format file

IniReplaceKeys("tt.ini",section,keylist);

Void IniSetFile
IniSetFile(sFile)
Sets default filename for most IniXXX functions

inisetfile("tt.ini");

Void IniSetStr
IniSetStr(sSec,sName,sStr)
Writes sName with sStr in section sSec

inisetstr(sect, name, "data");

Void IniSync
IniSync(sFile,iSize)
Flushes file buffer. The iSize argument sets the size of the RAM buffer.

  iSize
-1 Standard buffer size (8k)
0 Normal sync
0 New buffer size in kilobytes. (Maximum value 63.)

inisync("",0);

Boolean IsDir
IsDir(sPath)
Returns true if path specified is a directory.

b = isdir("d:\\century");

Integer LogFile
LogFile(sFile)
Opens a log file. Returns 0 on success or 1 on failure. Only one log file may be open at a time.

log = LogFile("C:\\TT.log");

IntegerLogFile_Close
LogFile_Close()
Closes the current log file. Returns 0 on success or 1304 on failure.

LogFile_Close();

Integer Mkdir
Mkdir(sDirName)

Creates new directory sDirName in the current directory. Returns 0 on success and an error code on failure.

mkdir("century");

String MkTempNam
MkTempNam(iFhead,iFext)
Returns a name for a temporary file
filename = mktempname("temp","tpx"); // creates file name similar to
// "temp037e9085412.tmp"

Void Spawn
Spawn( iWait, sCmdString, sArguments )
Passes sCmdString to the operating system to be run with the arguments sArguments. Note that the command name, without an extension, must always be the first argument in sArguments. Note that you cannot use quotes as part of sCmdString or sArguments, so if you must launch an application with a space in its Windows filename, you must use DOS 8.3 filenames to refer to that application with the spawn command.

  iWait
0 Wait until spawned process ends before running next command
1 No wait
2 Detach spawned process from the console
3 Wait for spawned process to complete its startup procedures before continuing with the next command

spawn( 0, "notepad.exe", "notepad untitled.txt" );

String StdDirectory
StdDirectory(sStartDir,sCaption)

Shows standard file open dialog for directories. Returns the full path to the directory chosen.

dpath = StdDirectory("d:\\century","TPX FILES");

String StdFont
StdFont()
Shows a standard font selection dialog. Returns a comma-delimited string of the font chosen, a zero, and the selected point size.

Font = StdFont();
String StdOpen
StdOpen(sDir,sMask,sExten,sCaption);
Opens a Windows standard file browser, returns selected path and filename.
filepath = StdOpen("d:\\century","exe files|*.exe|","exe","Exe Files");

String StdOpenButton
StdOpenButton( sDir, sMask, sExten, sCaption, sButton, iType)
Opens a Windows standard file browser with an additional button titled sButton. The browser dialog box will show an Open or Save button based on the iType.

  iType
0 Open dialog box
1 Save dialog box

Returns *button if the user clicks on the additional button, otherwise StdOpenButton returns the path and filename the user selected.

file = StdOpenButton( "d:\\century", "exe files|*.exe|All Files (*.*)|*.*|", "exe", "Select an Executable","Button Text", 1);

String StdPreview
StdPreview( sDir, sTitle )
Runs StdOpen and also displays previews of graphics files

file = StdPreview( "d:\\century", "Images" );

Handle StdPrint
StdPrint()
Shows a print setup dialog. The return value is a display context handle.

hPrint = StdPrint();

String StdSave
StdSave( sPath, sDesc, sExt, sTitle )
Opens a Windows save browser. Returns the path and filename the user selected, or an empty string if the user chooses Cancel.

StdSave( "c:\\temp\\Century", "Text file (*.txt)|*.txt|All Files (*.*)|*.*|", "", "Save As" );

String Uniq
Uniq(sFile)
Tests whether a file can be created. Returns the file name if the file can be created, or a zero-length string if it cannot.

filename = Uniq(testfile);

Void WriteLog
WriteLog(sMsg)
Writes text to the log file

WriteLog(“Message text.\r\n");

Back to Top

 


3.3 User Interface Commands

Boolean AddResFile
AddResFile(sFileName)
Adds a resource file to the internal list of files searched for resource data

AddResFile("ttdlgus.res");

Handle CreateForm
CreateForm( iFormNum, oParentObject, iDefPage )
Finds DIALOG or CENTABDLG resource from resource list and creates a modeless dialog whose parent is oParentObject. If the form is a tabbed dialog and iDefPage is nonzero, that page is selected. Returns zero on error.

hwnd = CreateForm( 1500, ObjFrame, 0);

Void EnableToolTips
EnableToolTips(bBool)
Enables or disables tooltips

EnableToolTips(0);

Object GetObject
GetObject(sObjectName)
Gets the object of string

obj = GetObject("CS103");

Object GetObjectFromHWND
GetObjectFromHWND(hWnd)
Returns an object from window handle

obj = GetObjectFromHWND(hwnd);

Handle GetObjectHWND
GetObjectHWND(oObject)
Gets hwnd from an object

hwnd=GetObjectHWND(object);

Integer GetObjectID
GetObjectID(oObject)
Gets object ID for oObject

IDnum = GetObjectID(object);

String GetObjectName
GetObjectName(oObject)
Gets the name of object oObject

oName = GetObjectName(object);

Integer LoadFile LoadFile(sFile,iFlag)
Loads a *.int file. Returns 0 if the file cannot be found. If iFlag is set to 2, the outer block of the loaded file will be executed.

status = LoadFile(“test.int”,0);

String LoadString
LoadString(iID,iLanguage)
Gets a string resource from resource list.

str = LoadString(200,0);

Integer ModalForm
ModalForm(iFormNum,oParentObj,iDefPage)
Reads DIALOG or CENTABDLG resource and runs modal dialog.

nIDCloseButton = ModalForm(1300,DlgObj,0);

Void ObjRegisterFormTooltips
ObjRegisterFormTooltips(hWnd)
Re-registers a form's tooltips. Normally this occurs automatically

ObjectRegisterFormTooltips(hwnd);

Object ResLoadMenu
ResLoadMenu(sStr)
Finds menu resource from resource list and creates a Win32 menu handle.

pmenu = ResLoadMenu("#400");

Void sl_FormExit
sl_FormExit( sObjName, iExitCode )
Causes a return from ModalForm with iExitCode as the return value.

sl_FormExit( DlgObj, IDOK );

Back to Top

 


3.4 Utility Commands

Void _Abort
_abort()
Abort script language execution

_Abort();

Integer _Asc
_Asc(sStr)
Returns ASCII value of the first character of sStr

n = _Asc("Q");

String _Chr
_Chr(iAsciiVal)
Converts integer ASCII value to single character string

str = _Chr(42);

String _HexStr
_HexStr(iInteger)
Converts integer value to hexadecimal string

hex = _HexStr(42);

Boolean _IsIn
_IsIn(sString, iAsciiValue)
Returns true if the character identified by iAsciiValue is in sString

yes = _IsIn("12345",_asc(“3”));

Boolean _IsSpace
_IsSpace(iAsciiValue)
Returns true if the character identified by iAsciiValue is a space, tab, carriage return or newline

yes = _IsSpace(_asc(“ “));

Integer _SizeOf
_SizeOf(sStr)
Returns length of string

n = _SizeOf("12345");

String _Str
_Str(iVal)
Returns string from numeric value iVal

a = _Str(12);

Integer _StrnCmp
_StrnCmp(sString1,iOffset1,sString2,iOffset2,iLen)
Compares sString1, starting at iOffset1, with sString2, beginning at iOffset2, for iLen characters. Returns -1 if sString1 is lesser, 1 if it’s greater, or 0 if they’re equal.

a = _StrnCmp(“handle”,3,”spindle”,4,4);

Integer _StrnCmpi
_StrnCmpi(sString1,iOffset1,sString2,iOffset2,iLen)
As _StrnCmp, but ignores case.

a = _StrnCmpi(“HANDLE”,3,”spindle”,4,4);

Void _ToLower
_ToLower(sStr)
Converts sStr to lower case

_ToLower("aBaB");

String _ToLowerC
_ToLowerC(sStr)
Returns string with all lower case

str = _ToLowerC("aBaB");

Void _ToUpper
_ToUpper(sStr)
Converts sStr to upper case

_ToUpper("aBaB");

String _ToUpperC
_ToUpperC(sStr)
Returns string with all upper case

str = _ToUpperC("aBaB");

Integer _Val
_Val(sStr)
Returns integer from a string

a = _Val("123");

Integer _VarType
_VarType(sVarName)
Returns the type for a named variable

  Return
0 Undefined variable
1 Integer, Boolean or uninitialized variable
2 String
17 Integer array
18 String array
32 System variable

vtype = _VarType("file");

Time Value AtoD
AtoD(sDateTime)
Converts ASCII time string sDateTime to internal time value

tim = AtoD("03/15/1999.01:23:45");

String Cdate
Cdate(tTime)
Converts internal time value to ASCII date string

str = cdate(time());

String Chname
Chname(iNum,iType) Converts ASCII character value to string for display as mnemonic, control or dump

  iType  
2 Numeric hex values 0d
3 Mnemonic ASCII values <CR>
4 Control characters ^M
5 Keystroke names ENTER

str = chname(13,0);

String Ctime
Ctime(tTime)
Returns clock time string from time value

hour = ctime(time());

String Decrypt
Decrypt(sString)
Decrypts an encrypted string

str = decrypt(password);

String Encrypt
Encrypt(sStr)
Encrypts a passed string

str = encrypt(password);

String Field
Field( sList, iPosNum, iSeparator )
Gets a string from a delineated list

str = field( "a|b|c|d|e", 2, _asc( "|" ) );

String GetEnv
GetEnv(sLABEL)
Gets value of environmental variable

name = getenv("HOME");

String GetSysDir
GetSysDir()
Returns directory TinyTERM is installed in

sdir = GetSysDir();

String GetUserDir
GetUserDir() Returns user's TinyTERM local directory, if different from system install directory.

path = GetUserDir();

Void Help
Help(sTopic)
Runs Windows help system on topic sTopic. If sTopic is not found or is zero length, the main help window will open.

Help("");

String Left
Left(sStr,iLen)
Returns leftmost iLen characters of string sStr.

a = left("12345",2);

Integer Main_Exit
Main_Exit(iRetVal)
Exit TinyTERM and return iRetVal. Must be followed by a Return statement.

Main_Exit(2);

String MidStr
MidStr(sStr,iPos,iLen)
Returns string starting at iPos of length iLen.

str = MidStr("12345",2,3);

Integer Opsys2
Opsys2()
Returns an integer that identifies the operating system

OS = opsys2();

Integer Pos
Pos(sStr1,sStr2,iStart)
Returns position of string 1 within string 2, beginning at character number iStart. You must set iStart to 1 or higher; values less than 1 will always return 0.

a = pos("23",1123334445,1);

Integer Quit
Quit(iExitCode)
Exits TinyTERM application. Note that in this version of CScript, you must follow quit commands with a return command.

Quit(0);
Return(1);

String Right
Right(sStr,iLen) Returns the rightmost iLen characters of sStr

a = right("123456",3);

Integer RmDir
RmDir(sPath)
Removes directory sPath. Returns 0 for success, 1 if sPath contains wildcard characters, or 1279 for failure.

success = RmDir(“C:\\Temp”);

Void SetUserDir
SetUserDir(sPath)
Sets user search directory

SetUserDir("\\Century");

VoidSleep
Sleep(nMilliseconds)
Pauses for nMilliseconds.

Sleep( 10000 );      // Pauses execution for 10 seconds

String StrConv
StrConv( sStr, iType )
Converts raw ASCII strings to strings with caret-prefixed control characters and hexidecimal character codes for doublequotes ("\x22"), quotes("\x27"), and dollar signs ("\x24"). Will also convert converted string back to raw ASCII.


  iType
0 Convert strings with converted characters to ASCII
1 Convert control characters to caret-prefixed characters
2 Convert control characters to caret-prefixed characters and convert double quotes, quotes, and dollar signs to hexidecimal sequences

str = strconv("Line one^M^M^MLineTwo^M",0);

String StrHex
StrHex(iInt,iLen)
Gets hex number of length iLen from integer iInt

a = strhex(12,2);

Integer Sum
Sum( sString, iType, iStartVal )
Calculates integer checksum of string starting with iStartValu as the beginning checksum value.

  iType
0 Adds all characters together
1 Xors all characters together
2 Returns the CRC checksum of the string

i = sum( "string", 0, 0 );

Integer Time
Time()
Returns current time as an internal time value. This is the number of seconds since 01/01/1970.00:00:00 GMT.

tim = time();

String Trim
Trim(sStr)
Returns string without trailing spaces

str = trim(s);

Back to Top

 


3.5 Win32 Commands

Void CheckMenuItem
CheckMenuItem( hMenu, iItemID, iFlag )
Calls Win32 CheckMenuItem to check or uncheck a menu item.

  iFlag
0 Uncheck menu item iItemID
8 Check menu item iItemID
1024 Uncheck the menu item at the zero-based relative position iItemID
1032 Check the menu item at the zero-based relative position iItemID

CheckMenuItem( GetFrameMenu(Frame), 7048, 8 );

Void ContextHelp
ContextHelp(hWnd)
Sends an SC_CONTEXTHELP message to the window associated with the object. This will change the mouse cursor to a question mark with a pointer. Clicking on a control after this should open a contextual help window.

ContextHelp(hwind);

Void DeleteMenuBarItem
DeleteMenuBarItem(hMenu,iItem,iFlag)
Deletes item number iItem from menu hMenu. If iFlag is set to 0, then iItem is the actual menu item number. If iFlag is non-zero, iItem is the zero-based position of the item in the menu.

DeleteMenuBarItem(hmenu,1,1);

Void DestroyMenu
DestroyMenu(hMenu)
Calls Win32 DestroyMenu function. Used to destroy menu loaded with ResLoadMenu

DestroyMenu(hmenu);

Void DrawMenuBar
DrawMenuBar(hWnd)
Draws the Menu Bar

DrawMenuBar(Frame);

Void EnableMenuItem
EnableMenuItem(hMenu,iItem,iTag)
Calls Win32 EnableMenuItem function

EnableMenuItem(hMenu,700,MF_DISABLED);

Void EnableWindow
EnableWindow(hWnd,iInt)
Calls Win32 EnableWindow function

EnableWindow(hwnd,0);

Handle FindWindow
FindWindow( sClassName, sWindowName )
Retrieves a handle to the top-level window that matches the class name and window name specified.

FindWindow( "dbMon", NULL );

String GetDeviceConfig
GetDeviceConfig(sDevice)
Gets configuration information for device sDevice

config = GetDeviceConfig(DevName);

Object GetDlgItem
GetDlgItem(hWnd,iSessID)
Calls Win32 GetDlgItem function

object = GetDlgItem(Frame,1);

Object GetFrameMenu
GetFrameMenu(hWnd)
Returns the frame object's menu handle.

hmenu = GetFrameMenu(hFrame);

Object GetSubMenu
GetSubMenu(hWnd,iInt)
Calls Win32 GetSubMenu function

hmenu = GetSubMenu(hmenu,0);

Object GetSystemMenu
GetSystemMenu(hWnd,bBool)
Calls Win32 GetSystemMenu function

hmenu = GetSystemMenu(Frame,0);

Integer GetSystemMetrics
GetSystemMetrics(iHW)
Calls Win32 GetSystemMetrics function.

n = GetSystemMetrics(SM_CXSCREEN);

String GetTapiNames
GetTapiNames()
Returns names of installed modems

list = GetTapiNames();

Void InsertMenuItem
InsertMenuItem(hMenu,iInt1,iItemPos,iMenuItemNum,sLabel)
Calls Win32 InsertMenuItem function to add a single item to an existing menu

InsertMenuItem(GetSubMenu(GetFrameMenu(Frame,4),3),0,MF_BYPOSITION,ITEM_NUMBER,"About");

Void InsertMenuParent
InsertMenuParent(hMenu,iInt1,iMenuPos,iMenuNum,sLabel)
Calls Win32 InsertMenu function to add a menu to an existing menu bar

InsertMenuParent(GetFrameMenu(Frame,4),0,MF_BYPOSITION,MENU_NUMBER,"About");

Void MoveWindow
MoveWindow( hWnd, iX, iY, iW, iH bRepaint )
Calls Win32 MoveWindow function.

MoveWindow( hFrame, x, y, w, h, 1 );

Void MenuStatus
MenuStatus(hMenu,iMenuItem,iStatus)
Changes the status of menu item number iMenuItem


  iStatus
0 Unchecks the menu item
1 Checks the menu item
2 Enables the menu item
3 Disables the menu item
4 Grays the menu item

MenuStatus(hmenu,7000,0);

Integer MsgBox
MsgBox(sMsg,sCaption,iType)
Display message box

  iType
0 OK button
1 OK and Cancel buttons
2 Yes and No buttons
3 Yes, No and Cancel buttons

msgbox("bad entry","ERROR",0);

Integer OpSys2
OpSys2()
Return operating system type

7 Windows 95, Windows 98 or Windows Me
15 Windows 2000 or Windows XP
71 Windows NT 4.0

os_num = opsys2();

Void RemoveMenuItem
RemoveMenuItem(hMenu,iMenuItem,iInt)
Calls Win32 RemoveMenu to remove a menu item

RemoveMenuItem(GetSystemMenu(Frame,0),MENU_DISCONNECT,0);

Void SetDragMode
SetDragMode(hWnd)
Capture move and release

SetDragMode(hwnd);

Integer SetErrorMethod
SetErrorMethod(iMethod)
Sets the method used to display error messages. Returns the previous setting.


  iMethod
0 Use message boxes
1 Write to Stderr
2 Do not display errors
3 Write to the debug monitor

previous = SetErrorMethod(0);

Boolean SetFocus
SetFocus(hWnd) Calls Win32 SetFocus to set window focus to hWnd

target = SetFocus(hwnd);

Boolean SetForegroundWindow
SetForegroundWindow( hWnd )

Calls Win32 SetForegroundWindow to bring the window specified in hWnd to the foreground and made the active window.

SetForegroundWindow( hwnd );

Integer SetFrameHMENU
SetFrameHMENU(hWnd,iMenuID)
Attach a menu to a frame window. Returns the handle of the menu previously attached to the window.

SetFrameMenu(hFrame,MenuID);

Void SetFrameMenu
SetFrameMenu(hWnd,iMenuResourceID)
Attach a menu to a frame window. Returns the handle of the menu previously attached to the window.

SetFrameMenu(hFrame,MenuID);

Boolean SetHelpFile
SetHelpFile(sFileName)
Sets name of default help file.

SetHelpFile("tt.hlp");

Boolean SetHelpID
SetHelpID(hWnd,iHelpID)
Associates a context help ID with a window

success = SetHelpID(hwnd,7748);

Void ShowWindow
ShowWindow(hWnd,iCmdShow)
Calls Win32 ShowWindow function

ShowWindow(hwnd,SW_SHOW);

Void TrackPopupMenu
TrackPopupMenu(hMenu,bBool,iHPos,iVPos,hWnd)
Calls Win32 TrackPopupMenu function

TrackPopupMenu(GetSubMenu(pmenu,0),0,x,y,Frame);

Back to Top

 


3.6 TinyTERM Commands

Void AppRedraw
AppRedraw()
Redraws application user interface.

AppRedraw();

Boolean CompileFile
CompileFile(sFilename)
Loads and executes a CScript file. Returns true if the file ran successfully.

success = CompileFile(“jackpot.cs”);

Integer CompileString
CompileString(sCommand)
Executes a CScript command string. Returns 1 if the command had no errors or -1 if there were errors.

status = CompileString(“count++;”);

String ConfigureDevice
ConfigureDevice(iIndex,sDeviceName,hWnd)
Gets modem configuration.

dconfig = ConfigureDevice(1,cdevice,HWND);

String CSLdebug
CSLdebug(sArg)
Returns CScript debugging information based on argument sArg.

  sArg
? List all other arguments
q Quit and exit
g Go
t [n] Trace n steps
l fname Load file fname
d Dump symbol dictionary
d sym Dump symbol sym. Can be wildcarded.
d n cnt Dump stack value n
bp List break points
bp sym Set break point on symbol sym
bd sym Delete break point on symbol sym
bd * Delete all break points
st Stack trace
r Register dump
u sym Unassemble code for symbol sym
. Display current instruction (not enabled)

symdic = CSLdebug(“d”);

String GenerateURL
GenerateURL( sSystem, sUsername, sPassword, sStr, iInt, iInt2, iInt3 )
Generates URL using operator entries.

str = GenerateURL( "www.censoft.com", "anonymous", pword, "", 0, 0, 0 );

String GetCountryList
GetCountryList()
Gets countries supported by modem location list

list = GetCountryList();

String GetDefaultBrowser
GetDefaultBrowser()
Gets default browser name and path

filename = GetDefaultBrowser();

String GetDefaultBrowserAppName
GetDefaultBrowserAppName()
Gets only default browser filename

file = GetDefaultBrowserAppName();

String GetLocationList
GetLocationList()
Gets locations supported by modem

list = GetLocationList();

Integer GetPropInt
GetPropInt(oObject,sPropertyName)
Returns the integer value of property sPropertyName associated with object oObject. Returns 0 if the object or property cannot be found.

propval = GetPropInt(hwnd,propname);

String GetPropStr
GetPropStr(oObject,sPropertyName)
Returns the string value of property sPropertyName associated with object oObject. Returns a zero-length string if the object or property is not found.

propval = GetPropInt(hwnd,propname);

Boolean IsDebugMode
IsDebugMode()
Returns true if "-debug" is set in command line.

b = IsDebugMode();

Integer IsSess
IsSess(oSession)
Returns session number for object oSession

sessnum = IsSess(CSESS);

Void KeyLoad
Keyload(sKeyFile,sSection,iFlag)
Loads keyboard definition sSection from keyboard file sKeyFile. iFlag is not used.

KeyLoad(“keyboard.dat”,”Default.keyboard”,0);

Integer KeySave
KeySave(sKeyFile,sSection)
Saves the current keyboard mappings to sSection of sKeyFile. Returns 0 on success or -1 on failure.

KeySave(“keyboard.dat”,”New section.keyboard”);

Void Menu_Draw
MenuDraw()
Redraws the Menu Bar if enabled

menu_draw();

Integer PerformLicenseCheck
PerformLicenseCheck(sProdCode,iBitmask,iVersion,bErrMsg)
Tests whether a Century product is licensed. The version is always 1024 for TinyTERM version 4. If bErrMsg is set, a message window will pop up if there are any errors. The valid product codes for TinyTERM 4.20 and 4.21 are:

  sProdCode
EV3 TinyTERM Emulator
PL3 TinyTERM Plus Edition
TC3 TinyTERM Thin Client Edition
WS3 TinyTERM Web Server Edition

The possible return codes are:

  iRetVal
0 Invalid license
1 Valid license
2 Expiration reminder needed
4 Expired evaluation license
8 No license found

menu_draw();

Void Script_Login
Script_Login()

Callback function called after login completes. Note: when using any of the Script_ commands, you should avoid using dialog boxes if you will be running from within a browser.

script_login();

Void Script_Logout
Script_Logout()
Callback function called before logout begins

script_logout();

Void Script_SessConnect
Script_SessConnect()
Callback function called after connecting to the host

script_sessConnect();

Void Script_SessDiscon
Script_SessDiscon()
Callback function called before disconnecting from the host

script_sessDiscon();

Void Script_SessDown
Script_SessDown()
Callback function called before the session is closed

script_sessdown();

Void Script_SessUp
Script_SessUp()
Callback function called after the session is opened

script_sessup();

Void Script_ShutDown
Script_ShutDown()
Callback function called before shutdown

script_shutdown();

Void Script_StartUp
Script_StartUp()
Callback function called after startup

script_startup();

Void SessDel
SessDel( oSession )
Deletes session with object oSession.

SessDel( CSESS );

Void SessionNew
SessionNew(sTpxFile);
Starts a new session

SessionNew("c:\\tmp\\default.tpx");

Void Setkey_Reset
Setkey_Reset(iFlag)
Resets all keyboard macros. If iFlag is set to 0, all emulator keys will be reset as well.

Setkey_Reset(1);

Void StatusBar_Draw
StatusBar_Draw()
Redraws Status Bar if enabled

StatusBar_Draw();

Void SwitchSess
SwitchSess(nSessNum,iSave)
Switches to session nSessNum. iSave is currently non-functional

SwitchSess(3,0);

Back to Top

 


3.7 Javascript Commands

Void Break
Break;
Exit current command loop and continue script past its end.

Break;

Void Continue
Continue;
Restarts loop processing from the first command.

Continue;

Void Do … While
Do { commands } While ( condition );
Execute commands until condition is met. The commands will always be executed at least once.

i = 0;
Do {
      i++;
} While ( i < 10);

Void For
For (iVar; condition; operation) { commands }
Execute commands until condition is met.

For (i = 1; i < 15; i * 2) { dprintln(_str(i)); }

Void Function
Function fname( variables ) { commands }
Creates a function named fname. If variables are named, they must be passed to the function.

Function example(sTitle) {
      msgbox(“The function works”,sTitle,0);
}
example(“My title”);

Void If … Else
If ( condition ) { commands1 } Else { commands2 }
Conditionally executes commands. Else is not required.
If (i == 4) {
      msgbox(“i = 4”,”Value”,0);
}

Void Var Var vName Initialize variable vName. Multiple variables may be initialized with one command.

Var sTitle,iCount;

Void While
While ( condition ) { commands }
As Do, but commands will be executed only if condition is met.
i = 4;
While (i < 3) { i++;}

Back to Top

 


3.8 C Commands

Void Goto
Goto LABEL
Continue script execution at LABEL. The label must be followed by a colon.

Goto NEW_ZONE;
NEW_ZONE :

Void Switch … Case … Default
Switch (iValue) { Case … Default }
Executes one set of commands based on iValue.
Switch (time()%2) {
   Case 0 :
   te.DisplayNL(“Time is even.”);
   break;
   Case 1 :
     te.DisplayNL(“Time is odd.”);
     break;
    Default :
   te.DisplayNL(“Error in modulo operation.”);
}

Back to Top

 


3.9 DDE Commands

3.9.1 DDE Server Commands

Void DDE_Enable
DDE_Enable(bOnOff)
Enables or disables the DDE server.

DDE_Enable(1);

Void DDE_Name
DDE_Name(sName)
Sets the DDE server name.

DDE_Name(“TINYTERM”);

Void DDE_TimeOut DDE_TimeOut(iInterval)
Sets the DDE client/server timeout in milliseconds.

DDE_TimeOut(5000);

Back to Top

 


3.9.2 DDE Client Commands

Integer DDE_Advise
DDE_Advise(iChannel,sItem,sVar)
Requests an advise link on sItem from the DDE server application and stores the result in sVar. Returns 0 on success, 1 on failure, or 420 if iChannel is not open.

result = DDE_Advise(1,”Name”,”sName”);

Void DDE_Close
DDE_Close(iChannel)
Closes a DDE channel.

DDE_Close(1);

Void DDE_CloseAll
DDE_CloseAll()
Closes all DDE channels.

DDE_CloseAll();

Integer DDE_Execute
DDE_Execute(iChannel,sTransaction)
Executes a DDE transaction. Returns 0 for success, 1 for failure, or 420 if iChannel is not open.

DDE_Close(1,CmdStr);

Integer DDE_Init
DDE_Init(iChannel,sService,sTopic)
Opens a DDE channel. Returns 0 on success or 1 on failure.

result = DDE_Init(1,sApp,AppTopic);

Integer DDE_Poke
DDE_Poke(iChannel,sItem,sData)
Sends data to the DDE server. Returns 0 on success, 1 on failure or 420 if iChannel is not open.

DDE_Poke(1,AppItem,DataString);

Integer DDE_Request
DDE_Request(iChannel,sItem,sVar)
Requests data from the DDE server and stores it in sVar. Returns 0 on success, 1 on failure or 420 if iChannel is not open.

DDE_CloseAll();

Integer DDE_Unadvise
DDE_Unadvise(iChannel,sItem)
Closes the advise link on sItem in a DDE conversation. Returns 0 for success, 1 for failure, or 420 if iChannel is not open.

DDE_Unadvise(1,AppItem);

Back to Top