ÝÛÛÛÛÛÛÛÛÛÛÛ ÝÛÛÛÛÛÛÛÛÛÝ ÝÛÛÛÛÛÛ ÝÛ ÝÛ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÛÛÛÝ ÝÛÛÛÛ ÝÛ ÝÛÛÛÛÛÛ ÝÛÛÛÛÛ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÛÛÛÛÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÝ ÝÛÛÛÛÛÛ ÝÛÛÛÛÝ ÝÛ ÝÛ ÝÛÛÛÛÛÛ ÝÛÛÛ ÝÛ ÝÛ ÝÛ Telemate Script Language Version 4.21 By Tsung Hu, White River Software Copyright (c) 1988-1996 White River Software. All rights reserved. TELEMATE SCRIPT TABLE OF CONTENTS i TABLE OF CONTENTS INTRODUCTION 1 Using TMS.EXE, the Script Compiler . . . . . . . . . . . . . . . . 1 To Run a Script . . . . . . . . . . . . . . . . . . . . . . . . . . 2 What Is Your Name . . . . . . . . . . . . . . . . . . . . . . . . . 2 DATA TYPES 3 Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 VARIABLES 6 Variable Identifiers . . . . . . . . . . . . . . . . . . . . . . . 6 Variable Declarations . . . . . . . . . . . . . . . . . . . . . . . 6 Predefined Variables . . . . . . . . . . . . . . . . . . . . . . . 6 CONNECTED . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 FOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 SUCCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 LOGGING . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 WIDTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 HEIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 EXPRESSIONS 11 Rule Of Precedence . . . . . . . . . . . . . . . . . . . . . . . . 11 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . 11 Boolean Operators . . . . . . . . . . . . . . . . . . . . . . . . . 12 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . 12 STATEMENTS 14 Comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Assignment Statement . . . . . . . . . . . . . . . . . . . . . . . 14 If Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Switch Statement . . . . . . . . . . . . . . . . . . . . . . . . . 16 While Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Repeat Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Exit Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 18 #include Directive . . . . . . . . . . . . . . . . . . . . . . . . 18 PROCEDURES 19 Procedure Declaration . . . . . . . . . . . . . . . . . . . . . . . 19 Parameter Declaration . . . . . . . . . . . . . . . . . . . . . . . 20 Calling Procedure and Parameter Passing . . . . . . . . . . . . . . 20 Nested Procedures and Scope of Variables . . . . . . . . . . . . . 22 Return Statement . . . . . . . . . . . . . . . . . . . . . . . . . 23 TELEMATE SCRIPT TABLE OF CONTENTS ii BUILT IN PROCEDURES BY CATEGORY 24 Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Print Statement . . . . . . . . . . . . . . . . . . . . . . . . 24 COM I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Put Statement . . . . . . . . . . . . . . . . . . . . . . . . . 25 Waitfor Statement . . . . . . . . . . . . . . . . . . . . . . . 25 File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 String Handling . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Miscellaneous Routines . . . . . . . . . . . . . . . . . . . . . . 26 BUILT IN PROCEDURES 27 Alarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Append . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 At . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Atoi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 ChDir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Clear COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Clear Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Clear Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 ComInCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 ComOutCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Concat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Create . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Dos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 ExitTelemate . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 FileExist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 FileSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 GetCh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 HangUp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 InputCh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Itoa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Keystroke . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 LoadFon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 LoadKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 LoadMac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 LoadPad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 LogOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 LogOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 LogPause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 LogResume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 TELEMATE SCRIPT TABLE OF CONTENTS iii Put . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 ReadCh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Receive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Seek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Send . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 StrDel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 StrIns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 StrPos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 StrSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 SubStr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Tell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Waitfor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 WaitUntil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 When . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 WhenIdle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 WhereX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 WhereY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 TOOLBOX PROCEDURES 65 Toolbox #1 65 Color Values and ANSI Color Codes . . . . . . . . . . . . . . . 66 EchoToLocal and EchoToRemote . . . . . . . . . . . . . . . . . . 66 Echo and EchoInt . . . . . . . . . . . . . . . . . . . . . . . . 66 EchoBkColor . . . . . . . . . . . . . . . . . . . . . . . . . . 67 EchoBlink . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 EchoBlock . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 EchoBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 EchoClearScreen . . . . . . . . . . . . . . . . . . . . . . . . 69 EchoColor . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 EchoGotoXY . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 EchoHiLite . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 EchoNormal . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 EchoReverse . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Toolbox #2 72 GetN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 InputN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 ReadN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 isalpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 isalnum . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 iscntl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 isdigit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 TELEMATE SCRIPT TABLE OF CONTENTS iv Toolbox #3 75 ConvertDate . . . . . . . . . . . . . . . . . . . . . . . . . . 75 DiffDate . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 DiffTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 PhoneDirectory . . . . . . . . . . . . . . . . . . . . . . . . . 78 PhoneFind . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 PhoneRead . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 PhoneSize . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 PhoneWrite . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 APPENDIX A: ERROR MESSAGES 81 Compiler Error Messages . . . . . . . . . . . . . . . . . . . . . . 81 Runtime Error Messages . . . . . . . . . . . . . . . . . . . . . . 83 INDEX 84 TELEMATE SCRIPT INTRODUCTION 1 INTRODUCTION ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ TMScript allows you to write procedures to perform repetitive functions, such as a log on script, as well as specific applications, such as the host mode. TMScript is designed to be a easy-to-use language. TMScript looks similar to the Pascal language and the syntax is as loose as that of BASIC language. For most of the users, only the WAITFOR, PUT and maybe the WHEN statements are necessary. For those users who have experience in the other programming language, TMScript is a powerful tool for communication related application. A script file can be created using almost all editors. The source file is a normal ASCII text file which contains a sequence of instructions telling Telemate what to perform next. The source file should use the extension .SCR to indicate that it is a SCRipt file. Using TMS.EXE, the Script Compiler ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Once the source file is written, it must be compiled (translated) to a form that Telemate can load and interpret quickly. To compile a source file, type TMS [/d] filename where is the filename of the source file. The extension can be omitted if it is .SCR. TMS.EXE compiles the file 'filename.SCR' and produces the compiled script file 'filename.TMS'. For example, typing 'TMS \TM\HOST', TMS compiles '\TM\HOST.SCR' and produces '\TM\HOST.TMS'. If a syntax error is encountered in the source file, the compiler reports the line number and the type of the error. You should edit the source file and recompile until there is no more errors. If the optional /d parameter is specified, the compiler will consider undeclared variable as an error. This option can be used when writing larger script and you want to ensure you declare all the variables and to avoid spelling mistake on the variable name. TELEMATE SCRIPT INTRODUCTION 2 To Run a Script ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ There are several ways to run a script. 1. Pressing [Alt S] at the Terminal Window opens the File Dialog and you are asked to identify which script file to be executed. 2. Put the script name in the link-script field of the phone directory. When the BBS is connected, the link-script is executed automatically. Link-scripts are sometimes referred as logon scripts because they perform repetitive logon procedure. 3. Type 'TM ' at the DOS command line. For example, C>TM HOST put Telemate in host mode when start. 4. You may assign a function key to execute a script file using the "^\" macro sequence. For example, the function key [Alt 4] is "^\host", when you press [Alt 4], the host script will be executed. 5. The SCRIPT statement allows you run another script in a script program. Please refer the description of the SCRIPT statement. What Is Your Name ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The first example program is a simple logon script. It waits for the logon prompts and sends the response to the remote system. WAITFOR "What is your name?"; wait for the logon prompt PUT "my name" ; send your name to remote system WAITFOR "is your password?" ; wait for the password prompt PUT "my password" ; send your name to remote system A script can be as simple as that and it will help you to logon to the remote system automatically. TELEMATE SCRIPT DATA TYPES 3 DATA TYPES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ TMScript provides two basic data types, integer and string, and four extended data types, character, boolean, date and time. Integer ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Ordinary number notation is used for integers. Decimal and engineering notation (e or E followed by an exponent) is not supported. Integer must within the range from -2147483648 to 2147483647. String ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ A string is a sequence of zero or more characters from extended ASCII character set (0-255), enclosed by quotation marks. A string with nothing in it is called a empty string. Two sequential quotation marks in a string denote a single character, an quotation mark. TMScript allows control characters to be embedded in strings. The '^' character followed by a letter (A-Z, a-z), '@' or '[' denotes a character of the ASCII code [Ctrl A] to [Ctrl Z], NULL, or ESC respective. Here are some examples of strings "TELEMATE" "This is a '""'." "^K^D" ; [Ctrl K] [Ctrl D] Character ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Character is represented as a string that contains only one character. For example, "A" is a character. Control codes are often used in script programs and are represented as Code String Description ÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Ctrl-@ "^@" NULL Ctrl-A "^A" ... .. Ctrl-H "^H" Backspace Ctrl-I "^I" TAB Ctrl-J "^J" LF, line feed ... .. TELEMATE SCRIPT DATA TYPES 4 Ctrl-M "^M" CR, Carriage Return, [Enter] ... .. Ctrl-Z "^Z" Ctrl-[ "^[" Escape Boolean ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Boolean (TRUE or FALSE) is represented as a integer. A integer is said to be TRUE if it is not equal to zero, FALSE if it is equal to zero. When testing a boolean condition, you should not use the following code, IF CONNECTED=1 ... ENDIF because the variable CONNECTED may have other values. Instead, you should use IF CONNECTED ... ENDIF to test if CONNECTED is TRUE. And IF NOT CONNECTED ... ENDIF to test if CONNECTED is FALSE. Date ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Date is represented as a string with the format "MM-DD-YY". When a date string is compared with another date string, they are first converted to the internal format "YYMMDD" so that the comparison returns the correct result. Note that the date format option in the main program does not affect the format in the script. For date conversion, see ConvertDate command in toolbox #3. TELEMATE SCRIPT DATA TYPES 5 Time ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Time is also represented as a string but with the format "HH:MM:SS". When two time strings are being compared, they are converted to the internal format "HHMMSS" such that the comparison can the correct result. TELEMATE SCRIPT VARIABLES 6 VARIABLES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Variable Identifiers ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ A variable identifier can contain letters and digits. However, a variable can only start with a letter. Case is not significant, in the other word, the variable is the same as . A variable identifier can be of any length, but only the first 8 characters are significant. For examples, the variable identifier is the same as . Variable Declarations ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ A variable declaration embodies a list of identifiers that designate new variables and their type. For example, INTEGER lower,upper,step ; integers STRING message,filename ; strings INTEGER true,false ; boolean STRING ch,letter ; character The variable declaration part should be placed at the beginning of a script or of a procedure. In TMScript, variables need not declared before use if no procedure is defined. Therefore, the variable declaration part can be skipped. Predefined Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ TMScript built in procedures do not return value. Several predefined variables are set to the resulting value. They are CONNECTED, FOUND, SUCCESS, LOGGING, WIDTH and HEIGHT. TELEMATE SCRIPT VARIABLES 7 CONNECTED CONNECTED is set to the number of the connected entry (from 1 to 1000). The variable CONNECTED returns to FALSE as soon as the carrier lost. On the other hand, if the state of the carrier changes from OFF to ON, CONNECTED is set to TRUE. IF NOT CONNECTED PRINT "It is not connected to a remote system." STOP ENDIF SWITCH CONNECTED CASE 1: PRINT "connected to #1" CASE 3: PRINT "connected to #3" CASE 6: PRINT "connected to #6" ENDSWITCH The CONNECTED variable is also used in conjunction with the DIAL statement. If the dialing is successful and connect to a remote system, the variable is set to the number of the connected entry. If the DIAL statement aborts without connection, the variable CONNECTED is set to FALSE, indicating that the DIAL statement is aborted by operator or the number of attempt exceeds the dial attempt setting. For example, DIAL "1 3 6" IF NOT CONNECTED PRINT "Dialing process aborted" STOP ENDIF SWITCH connected CASE 1: PRINT "connected to #1" CASE 3: PRINT "connected to #3" CASE 6: PRINT "connected to #6" ENDSWITCH Note that this variable reflects the online status only if your modem reports so. You should check your modem manual to ensure that the modem CD (carrier detect) signal is reflecting the actual online status. Most modems use a "&C1" AT command to set it and you should add it to the modem init string. TELEMATE SCRIPT VARIABLES 8 FOUND This variable is set to resulting value after the WAITFOR statement is executed. It is set to FALSE if time exceeded. Otherwise, it is set to the string number of the matched string. For example, WAITFOR "NO CARRIER","thanks for calling","hang up now",100 SWITCH FOUND CASE 1: PRINT "'NO CARRIER' found" CASE 2: PRINT "'thanks for calling' found" CASE 3: PRINT "'hang up now' found" ENDSWITCH SUCCESS This variable is used by several statements. The resulting values and descriptions is shown in the following table. Statement Value Description ÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Append TRUE the file is successfully opened or created FALSE cannot create file ChDir TRUE directory changed FALSE invalid path Close TRUE file closed FALSE cannot close file Create TRUE the file is successfully created FALSE cannot create file Delete TRUE the file is successfully deleted FALSE cannot delete file FileSize TRUE the file size is determined successfully FALSE cannot open file InputCh ch TRUE a character is read into FALSE no character is available LoadFon TRUE the phone directory is successfully opened FALSE the phone directory cannot be opened LoadKey TRUE the keyboard file is successfully opened FALSE the keyboard file cannot be opened LoadMac TRUE the macro table is successfully opened FALSE the macro table cannot be opened TELEMATE SCRIPT VARIABLES 9 LoadPad TRUE the keypad table is successfully opened FALSE the keypad table cannot be opened LogOn TRUE the log file is successfully opened FALSE the log file cannot be created Open TRUE the file is successfully opened FALSE the file does not exist Read str TRUE a line is read into FALSE end of file encountered. ReadCh ch TRUE a character is read into FALSE end of file encountered. Receive TRUE all files are received successfully FALSE file transfer aborted Rename TRUE the file is successfully renamed FALSE cannot rename file Seek TRUE the file pointer is moved successfully FALSE disk error Send TRUE all files are sent successfully FALSE file transfer aborted Tell pos TRUE the file pointer is stored in FALSE disk error Write TRUE write successary to file FALSE cannot write to file LOGGING This variable reflects the current file log status and has the values 0 log file close or log file not in use 1 log file open and capturing incoming data 2 log file in pause state WIDTH This variable stored the width of the zoomed terminal window which is equal to the screen width. Possible values are 80 or 132. TELEMATE SCRIPT VARIABLES 10 HEIGHT This variable is the height of the zoomed terminal window which is calculated as HEIGHT = screen height if ( menu bar present ) HEIGHT = HEIGHT - 1 if ( status line present ) HEIGHT = HEIGHT - 1 if ( HEIGHT < 24 ) HEIGHT = 24 For example, on EGA 43 line mode with both menu bar and status line present, HEIGHT is equal to 41. But on 25 line mode, HEIGHT is equal to 24, not 23, because Telemate's terminal has at least 24 lines though only 23 lines may be shown on screen. In this case, terminal will shift up and down to justify the display region. This variable may alter between two instructions if the users press [Alt -] to toggle the menu bar and status line. When programming full screen procedure, you should assume there are 23 lines in the screen and DO NOT scroll the screen by going to the last line and perform a line feed. TELEMATE SCRIPT EXPRESSIONS 11 EXPRESSIONS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Rule Of Precedence ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Expressions are made up of operators and operands. In complex expressions, rule of precedence clarify the order in which operations are performed. Operators Precedence ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄ *,/ first (high) +,- second =,<>,<,>,<=,>= third not fourth and, or, xor fifth (low) There are the rules of precedence 1. First, an operand between two operators of difference precedence is bound to the operator with higher precedence. 2. Second, an operand between two equal operators is bound to the one on its left. 3. Third, expressions within parentheses are evaluated prior to being treated as a single operand. Arithmetic Operators ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The types of operands for arithmetic operators are shown in the following table. Operators Operation Operand Type ÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄ + addition integer - subtraction integer * multiplication integer / division integer For example, the formula to convert Fahrenheit temperature to Celsius equivalents is celsius = (fahr-32) * 5 / 9 TELEMATE SCRIPT EXPRESSIONS 12 Boolean Operators ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The types of operands for arithmetic operators are shown in the following table. Operators Operation Operand Type ÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄ not negation boolean and logical and boolean or logical or boolean xor logical xor boolean Normal Boolean logic governs the results of these operations. For instance, 'a and b' is TRUE only if both an are TRUE. Relational Operators ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The types of operands for arithmetic operators are shown in the following table. They all have the same precedence. Operators Operation Operand Types ÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ = equal to integer, string, date, time <> not equal to integer, string, date, time > greater than integer, string, date, time >= greater or integer, string, date, time equal to < less then integer, string, date, time <= less then or integer, string, date, time equal to When the operands are integer, date or time, the comparison will produce the usual result such as Condition Result Operands Type ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄ 1 > 2 FALSE integer "12-31-89" < "01-01-90" TRUE date "00:00:00" > "23:59:59" FALSE time However, if the operands are strings, the operators "<", ">" and "<>" have another meaning such that you can determine if a string is a sub- string of another string. s1 < s2 if s1 is a sub-string of s2 s3 > s4 if s3 is a super-string of s4 s5 <> s6 if s5 is not a sub-string of s6 and s5 is not a super-string of s6 TELEMATE SCRIPT EXPRESSIONS 13 For example, Condition Result Explanation ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ "hello" = "Hello" TRUE TMScript is not case sensitive. "goodbye" < "bye" TRUE "bye" is a sub-string of "goodbye" "dog" <> "car" TRUE The string is not equal "abc" >= "xyz" FALSE "abc" is not a super-string of "xyz" and they are not equal. TELEMATE SCRIPT STRUCTURED STATEMENTS 14 STATEMENTS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Statements describe algorithmic actions that can be executed. Comment ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Any characters after ";" are ignored by the TMScript compiler. Assignment Statement ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Assignment statements replace the current value of a variable with a new value specified by an expression. The expression must be assignment-compatible with the type of the variable. The program prints the following table of Fahrenheit temperatures and their centigrade or Celsius equivalents. 0 -17 20 -6 40 4 ... ... 280 137 300 148 Here is the program itself. ; Print Fahrenheit-Celsius table ; for f = 0, 20, ... , 300 INTEGER lower,upper,step INTEGER fahr,celsius lower = 0 ; lower limit of temperature table upper = 300 ; upper limit step = 20 ; step size fahr = lower ; first item in the table WHILE fahr <= upper celsius = (fahr-32) * 5 / 9 ; calcuate the values PRINT fahr,"^I",celsius ; print the result fahr = fahr + step ; next item in the table ENDWHILE TELEMATE SCRIPT STRUCTURED STATEMENTS 15 If Statement ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The general form for IF statement is IF condition statements ENDIF The is executed only if is TRUE. Another form is IF condition statements-1 ELSE statements-2 ENDIF One and only one of the two statements associated with an is done. If the is true, is executed; if not, is executed. The construction IF condition-1 statements-1 ELSE IF condition-2 statements-2 ELSE IF condition-3 statements-3 ENDIF ENDIF ENDIF occurs so often that it is worth a new keyword ELSEIF. The statement can be re-written as IF condition-1 statements-1 ELSEIF condition-2 statements-2 ELSEIF condition-3 statements-3 ENDIF TELEMATE SCRIPT STRUCTURED STATEMENTS 16 Switch Statement ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The SWITCH statement is a special multi-way decision maker that tests whether an expression matches one of a number of values, an branches accordingly. The syntax for SWITCH statement is SWITCH expression CASE value-1: statements-1 CASE value-2,value-3: statements-2 OTHERWISE: statements-3 ENDSWITCH The SWITCH evaluates the expression and compares its value to all the cases. Each cases must be labeled by the values of the same type as the expression. Several values can be separated by comma. If a case matches the expression value, execution starts at that case and ends at the next case label. The case labeled OTHERWISE is executed if none of the other cases is satisfied. A OTHERWISE is optional; if it isn't there and if none of the cases matches, no action at all takes place. However, OTHERWISE, if exists, must be placed after all the case labels. The program counts digits, blanks, others. nDigit = 0 ; digit nBlank = 0 ; blank nOther = 0 ; others OPEN "MYFILE" ; open the file "MYFILE" READCH ch ; read the first character WHILE success ; if not end of file SWITCH ch CASE "0","1","2","3","4","5","7","8","9": ; is digit nDigit = nDight + 1 CASE " ": ; is blank nBlank = nBlank + 1 OTHERWISE: ; others nOther = nOther + 1 ENDSWITCH READCH ch ; read next character ENDWHILE CLOSE ; close the file PRINT nDigit ; print the results PRINT nBlank PRINT nOther TELEMATE SCRIPT STRUCTURED STATEMENTS 17 While Loop ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The WHILE loop is the most general loop. The syntax is WHILE condition statements ENDWHILE The is tested. If it is true, the body of the loop (all the statements before the keyword ENDWHILE is executed. Then the condition is re-tested, and if true, the body is executed again. When the test becomes false the loop ends, and execution continues at the statements that follows the loop. For example, to print the value from 1 to 100, you can write i = 1 ; start from 1 WHILE i<=100 ; check if it in the range PRINT i ; print the number i = i + 1 ; increase the counter by 1 ENDWHILE Repeat Loop ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ While the WHILE loop test the condition at the top, the REPEAT loop test it at the bottom. It tests at the bottom after making each pass through the loop body; the body is always executed at least once. Consider the loop REPEAT statements UNTIL condition The statements is executed, then the condition is evaluated. If it is false, the statements is evaluated again, and so on. If the condition becomes true, the loop terminates. For example, to print the value from 1 to 100, you can write i = 1 ; start from 1 REPEAT PRINT i ; print the number i = i + 1 ; increase the counter by 1 UNTIL i>100 ; repeat until it is NOT in the range TELEMATE SCRIPT STRUCTURED STATEMENTS 18 Exit Statement ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ It is sometimes convenient to be able to control loop exits other than by testing at the top or bottom. The EXIT statement provides an early exit from the loops. A EXIT statement causes the innermost loop to be exited immediately. The following program accept strings from keyboard, using a EXIT to exit from the loop when the string contains an [Esc] ("^["). REPEAT INPUT s IF "^[" <= s ; test if [Esc] is a sub-string of s EXIT ; before printing it ENDIF PRINT s UNTIL s = "" ; repeat until an empty string is entered #include Directive ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ This compiler directive allows you to write reusable procedures in a separate file and imports the procedures conveniently. The syntax is #include "includefile" The will be inserted as if it is physical appear in this point. The must be a pathname with extension. For example, #include "TOOLBOX.SCR" #include "MYLIB.SCR" inserts the TOOLBOX.SCR and MYLIB.SCR into this point. The #include directive can be nested as deep as 10 levels. TELEMATE SCRIPT PROCEDURE 19 PROCEDURE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ In TMScript, a procedure is equivalent to a subroutine or function in Fortran, or procedure in Pascal, C etc. A procedure provides a convenient way to encapsulate some computation in a black box, which can then be used without worrying about its innards. For example, to swap the values of two variables, and , you have to write three lines as follows temp = i ; put into a temporary variable i = j ; put into j = temp ; now put the value of into Suppose in your script there are a lot of swapping, it will be convenient to define a procedure called to perform the swapping. Then your main program will look like i = 1 j = 2 swap i,j ; now i=2, j=1 PRINT i ; 2 PRINT j ; 1 This is only a small usage of procedure. Imagine if the procedure is very complex, you can use it again and again once it is tested and performs what you need. Procedure Declaration ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ The syntax of a procedure definition is PROCEDURE ENDPROC is any valid identifier. can be omitted if the procedure does not required parameters. See next section for details on parameter declaration. made within a given procedure are visible only within that procedure. This part should ALWAYS be included in order to make the program easy to be traced although the declarations may be omitted. can be considered as a sub-program of the main program and obeys all the rule described above. TELEMATE SCRIPT PROCEDURE 20 Parameter Declaration ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Parameter declaration is similar to variable declaration. For example, PROCEDURE sample STRING s,t,INTEGER i,j declares the procedure with two string parameters and and two integer parameters and . You may use any combination of STRING and INTEGER to define parameters. For example, PROCEDURE sample INTEGER i,STRING p,q,r,s,INTEGER j,k,STRING z We can write the procedure as PROCEDURE swap INTEGER value1,value2 ; swap two integers INTEGER temp ; declare a local variable temp = value1 ; store the first value value1 = value2 ; replace with the second value value2 = temp ; replace with the first value ENDPROC After that, the main program may look like i = 1 j = 2 k = 3 swap i,j ; now i=2, j=1 swap j,k ; now j=3, k=1 PRINT i,j,k ; 2,3,1 Calling Procedure and Parameter Passing ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Once the procedure is defined, it can be called by putting the procedure name in the statement part. In the example, the statements i = 1 j = 2 swap i,j ; now i=2, j=1 PRINT i,j ; 2,1 call the procedure with the parameters and . In the above example, the method used to pass and to the procedure is called 'pass by reference' because and can be changed when return. There is another method called 'pass by value' of which the parameter cannot be changed. TELEMATE SCRIPT PROCEDURE 21 Consider the following procedure PROCEDURE countDown INTEGER num ; print from to 1 WHILE num >= 1 ; check if it is in the range PRINT num ; print it num = num-1 ; decrease until num=0 ENDWHILE ENDPROC countDown 100 ; pass by value n = 100 countDown n*2 ; pass by value (200) PRINT n ; n = 100 countDown (n) ; pass by value (100) PRINT n ; n = 100 countDown n ; pass by reference PRINT n ; n = 0 ! If we supply with the parameter 100, n*2 or (n), they are 'pass by value'. On the other hand, is 'pass by reference' in the last statement. The general rule of method of passing parameters is: When the parameter is a constant, an expression or surrounded by parentheses, it is 'pass by value'. Otherwise, it is a variable and is 'pass by reference'. The rule applies to string parameter as well. To prevent confusion, we should rewrite the procedure by introducing a local variable. PROCEDURE countDown INTEGER num ; print from to 1 INTEGER count ; introduce a local variable count = num ; if neccessary WHILE count >= 1 ; check if it is in the range PRINT count ; print it count = count-1 ; decrease until 0 ENDWHILE ENDPROC ; this does not change TELEMATE SCRIPT PROCEDURE 22 Nested Procedures and Scope of Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ TMScript allows nested procedures; you can declare one procedure inside of another. For example, PROCEDURE outer STRING i,j PROCEDURE inner INTEGER i i = 100 PRINT "i = ",i PRINT "j = ",j ENDPROC i = "This is string 'i'." j = "This is string 'j'." inner PRINT "i = ",i PRINT "j = ",j ENDPROC The procedure declares two string variables, and . These two variables can be accessed by both the procedure and the one because they are declared before the procedure. The procedure declares an integer variable . Although the two 's share the same name, they are not identical. The inner is visible in the procedure but not in the procedure. On the other hand, the outer can no longer be accessible in the procedure. The statement i = 100 does not affect the outer . This is called the scope rule. The output of the program is i = 100 j = This is string 'j'. i = This is string 'i'. j = This is string 'j'. TELEMATE SCRIPT PROCEDURE 23 Return Statement ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Like the EXIT statement, it is sometimes convenient to be able to return from a procedure at the middle of the procedure. The following procedure accept strings from keyboard and print it, using a RETURN to return from the procedure when the string contains an [Esc] ("^["). PROCEDURE acceptString STRING s INPUT s IF "^[" <= s ; test if [Esc] is a sub-string of s RETURN ; before printing it ENDIF PRINT s ENDPROC TELEMATE SCRIPT BUILT IN PROCEDURES BY CATEGORY 24 BUILT IN PROCEDURES BY CATEGORY ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Console I/O ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ There are eight statements in the group of console input and output. Namely, Input, InputCh, Print, AT, Clear Text, Clear Key, WhereX, WhereY PRINT Statement Output is simple, the PRINT statement can print variable or constant of types integer or string to the terminal window. For example, PRINT "hello, world" print the words hello, world to the terminal window. PRINT supplies a newline automatically. However, if a comma "," follows the string, no newline is supplied. The statement above could just as well have been written PRINT "hello, ", PRINT "world", PRINT to produce an identical output. The last PRINT statement supplies a newline. PRINT statement accepts more than one argument. Each two arguments are separated by a comma. For example, PRINT "x = ",x PRINT "My name is ",firstName," ",lastName PRINT COM I/O ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ As a communication program, TMScript provides thirteen I/O statements that communicate with the remote system. They are Get, GetCh, Put, Clear COM, ComInCount, ComOutCount HangUp, Receive, Send, Waitfor, When, WhenIdle TELEMATE SCRIPT BUILT IN PROCEDURES BY CATEGORY 25 PUT Statement COM output is as simple as console output, the PUT statement can send variable or constant of types integer or string to the remote system. For example, PUT "first last" send the words first last and a carriage return [Ctrl M] to the remote system. PUT supplies a carriage return automatically. However, if a comma "," follows the string, no carriage return is supplied. The statement above could just as well have been written PUT "first ", PUT "last", PUT to produce an identical output. The last PUT statement supplies a carriage return only. PUT statement accepts more than one argument. Each two arguments are separated by a comma. For example, PUT firstName,";",lastName,";",password WAITFOR Statement The WAITFOR statements waits for specified stirngs from the remote system in a specified time. In TMScript, you can specify more than one string to wait for. If any of them is received, the FOUND variable is set to a non-zero value (TRUE). Combined with the PUT statement, you can tell Telemate when to send a string to the remote system. Syntax Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ WAITFOR t Set default waiting time WAITFOR s1,s2, ... , sN Wait until one of the strings is received WAITFOR s1,s2, ... , sN, t Wait until one of the strings is received or waiting time exceeded TELEMATE SCRIPT BUILT IN PROCEDURES BY CATEGORY 26 For example, the following code segment are usally used in a logon script program. WAITFOR "first",30 ; wait for "first" in 30 seconds IF NOT FOUND STOP ; stop if prompt not found ENDIF PUT "my name" ; send the name WAITFOR "password",5 ; wait for "password" in 5 seconds IF NOT FOUND STOP ; stop if prompt not found ENDIF PUT "^&" ; send the password field (^&) in ; in the phone directory File Handling ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ One text file is allowed to open at a time. The file is open or created as a read/write file. The file handling procedures are Open, Created, Append, Read, ReadCh, Write, Seek, Tell, Close, ChDir, Delete, Rename, FileExist, FileSize The predefined variable SUCCESS is set to FALSE if there is any error. String Handling ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ A string is a sequence of character. The limit of the length of a string is 512 characters. When referring to a character position, the position is counted from 1. The string handling procedures are Atoi, Concat, Itoa, Length, StrDel, StrIns, StrPos, StrSet, SubStr Miscellaneous Routines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Alarm, Atoi, Date, Delay, Dial, Dos, ExitTelemate, Image, Itoa, Keystroke, LoadFon, LoadKey, LoadMac, LoadPad, LogOff, LogOn, LogPause, LogResume, Query, Script, Set, Time, WaitUntil TELEMATE SCRIPT BUILT IN PROCEDURES 27 BUILT IN PROCEDURES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Alarm ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Pop-up the alarm dialog. Syntax ALARM ALARM message Remarks If the string is specified, it is displayed in the alarm dialog. If the message is too long, it can be split to several lines by putting a "^J" between each line. Return If the operator press [Enter] or click the OK button in the alarm dialog, SUCCESS is set to TRUE (non-zero). If the operator press [Esc] or the alarm time excess, SUCCESS is set to FALSE (zero). See also Set AlarmSound, Set AlarmTime Example RECEIVE "s" IF NOT SUCCESS ALARM "Warning: File transfer aborted" IF NOT SUCCESS ; if timeout, print message on screen PRINT "Warning: File transfer aborted" ENDIF ENDIF ALARM "Alarm:^JThis is a^Jvery long message" Append ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Opens a text file, creates it if necessary, and moves the file pointer to the end of the file. Syntax APPEND filename Remark APPEND opens the text file as a read/write file and strip the ending EOF [Ctrl Z]. Return Upon successful completion, SUCCESS is set to TRUE. If the file cannot be created, SUCCESS is set to FALSE. TELEMATE SCRIPT BUILT IN PROCEDURES 28 See also Create, Open At ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Positions cursor in terminal window. Syntax AT column,row Remark AT moves the cursor to the position within the terminal window. The upper left corner is (0,0) and the lower right corner is (79,24) if a 25 rows terminal is used. See also Print Atoi ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Converts a string to an integer. Syntax ATOI s,i Return contains the converted value or 0 if cannot be converted to a number. See also Itoa ChDir ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Changes current directory. Syntax CHDIR path Remark CHDIR causes the directory specified by to become the current working directory. must specify an existing directory. A drive can also be specified in but it changes only the current directory on that drive; it doesn't change the active drive. Return Upon successful completion, SUCCESS is set to TRUE; otherwise, SUCCESS is FALSE. See also Delete, FileExist, Rename TELEMATE SCRIPT BUILT IN PROCEDURES 29 Clear COM ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Clears the COM buffer. Syntax CLEAR COM Remark Data being sent and received are placed in a COM buffer, sometimes it is necessary to clear the buffer before processing. See also Get, GetCh, Put Example GET s ; get a string DELAY 50 ; wait for 5 seconds CLEAR COM ; clear the received data in the last 5 seconds GET s ; get another string Clear Key ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Clears the keyboard buffer and gives up keyboard control after a INPUT or INPUTCH statement. Syntax CLEAR KEY Remark CLEAR KEY clears the content of the keyboard buffer. Keyboard input before this statement are thrown away. When the INPUT or INPUTCH statement in the script is executed, the following input characters are placed in a keyboard buffer no matter if we want to read the next key or not. As a result, the following characters are NOT sent to the remote system automatically. It is important to give up the control of keyboard whenever no more keyboard input is needed and the clear key statement is built for this purpose. See also Input, InputCh Example PRINT "Input filename:" INPUT filename ; ask the user to input a filename CLEAR KEY ; give up keyboard control such that ; following keys are sent to remote ; system automatically TELEMATE SCRIPT BUILT IN PROCEDURES 30 Clear Text ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Clears the terminal window. Syntax CLEAR TEXT Remark CLEAR TEXT clears the terminal window and positions the cursor to the upper-left corner. It sets the display attribute to the initial setup. Close ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Closes a file. Syntax CLOSE Return Upon successful completion, SUCCESS is set to TRUE; otherwise, SUCCESS is FALSE. See also Open, Read, Write ComInCount ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Gets the number of characters in the incoming COM buffer. Syntax COMINCOUNT count Remark Telemate has an incoming COM buffer of 8000 bytes. Return contains the number of characters in the incoming COM buffer. See also Clear COM ComOutCount ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Gets the number of characters in the outgoing COM buffer. Syntax COMOUTCOUNT count Remark Telemate has an outgoing COM buffer of 2000 bytes. Return contains the number of characters in the outgoing COM buffer. TELEMATE SCRIPT BUILT IN PROCEDURES 31 See also Clear COM Concat ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Appends one string to another Syntax CONCAT dest,src Remark CONCAT appends a copy of to the end of the string . If the backspace character "^H" is encountered in , the last character of the concatenating string is erased. Return contains the concatenated string. See also Length, StrDel, StrIns Example s = "abc" ; s = "abc" CONCAT s,"xyz" ; s = "abcxyz" CONCAT s,"^H" ; s = "abcxy" CONCAT s,"pq" ; s = "abcxypq" Create ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Creates a new text file or rewrites an existing one. Syntax CREATE filename Remark CREATE creates the new text file . If the file already exists, the old file is deleted. Return Upon successful completion, SUCCESS is set to TRUE; otherwise, SUCCESS is FALSE. See also Append, Open Date ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Gets system date. Syntax DATE today TELEMATE SCRIPT BUILT IN PROCEDURES 32 Remark DATE fills the string with the current date. Dates can be compared with the usual '<', '>' and '=' relational operator. The date format option in the main program does not affect the format in the script language. Return contains the system current date in MM-DD-YY format. See also Time, ConvertDate Example DATE today IF today>="01-01-91" AND today<"01-05-91" PRINT "Happy New Year!" ENDIF Delay ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Suspends script execution for an interval. Syntax DELAY t Remark With a call to DELAY, the script program is suspended from execution for the number of tenth seconds specified by . Example DELAY 15 ; wait for one and a half second Delete ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Deletes one or more files Syntax DELETE filename Remark DELETE deletes one or more files specified by . Wildcards are allowed in . Return On successful completion, SUCCESS is set to TRUE; otherwise, SUCCESS is FALSE. See also FileExist, Rename TELEMATE SCRIPT BUILT IN PROCEDURES 33 Dial ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Dials a list of entries or redials the current list. Syntax DIAL DIAL list Remark DIAL redials the the current list of entries. If is specified, the current list is replaced by and start dialing. The option is the maximum of number of dialing attempt. The option can be used to specify the current dial list. Return DIAL sets CONNECTED to the number of the connected entry. If the operator press [Esc] to abort the dialing process or the attempts excess the option, CONNECTED is set to 0 (FALSE). See also Set AutoRedial, Set DialAttempt, Set DialList, Set DialPause, Set DialTime, Set MultiLine Example SET DialAttempt,3 ; try each entry once SET DialList,"1 3 6" ; set the dial list DIAL ; equivalent to a DIAL "1 3 6" statement IF NOT CONNECTED PRINT "All boards are busy." ELSE SWITCH CONNECTED CASE 1: PRINT "connected to #1" CASE 3: PRINT "connected to #3" CASE 6: PRINT "connected to #6" ENDSWITCH ENDIF SET DialAttempt,0 ; unlimit the maximum attempt Dos ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Jumps to DOS or issues a DOS command. Syntax DOS DOS command TELEMATE SCRIPT BUILT IN PROCEDURES 34 Remark The DOS statement invokes the DOS COMMAND.COM file to execute a DOS command, batch file, or other program named by the string . the program must be in the current directory or in one of the directories listed in the PATH environment string. If is not specified, the DOS statement jumps to DOS and return when users enter 'EXIT' in the DOS command line. If the or the option is turned on, Telemate swaps part of itself to second storage and, hence, leaves more memory space for the DOS shell. The COMSPEC envirnoment string is used to find the COMMAND.COM file. If your COMMAND.COM is not in the root directory - suppose in the C:\DOS directory, you should include the following in the AUTOEXEC.BAT startup file. SET COMSPEC=C:\DOS\COMMAND.COM See also Set SwapToDisk, Set SwapToEms, Set MaxDosShell Example QUERY SwapToEms,ems ; store the original options QUERY SwapToDisk,disk QUERY MaxDosShell,max SET SwapToEms,on ; provide more working space SET SwapToDisk,on ; for external program SET MaxDosShell,off ; DOS "TMSTAT TM.USE" ; run the TMSTAT.EXE program SET SwapToEms,ems SET SwapToDisk,disk ; restore the original options. SET MaxDosShell,max ExitTelemate ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Terminates Telemate's execution. Syntax EXITTELEMATE EXITTELEMATE exitCode Remark EXITTELEMATE terminates Telemate and return to DOS. The file in the Edit window is saved automatically if necessary. If is not specified, Telemate exits to DOS with the error level 0. Otherwise, the error level is set to . Typically a value of 0 is used to indicate a normal exit, and a nonzero value indicates some errors. TELEMATE SCRIPT BUILT IN PROCEDURES 35 FileExist ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Determines if a file or directory is exist. Syntax FILEEXIST filename,existFlag Remark FILEEXIST checks the file named by to determines if it is exists. Wildcards are allowed in . Return If the file is exist, is set to TRUE; otherwise, is FALSE. See also Delete, Rename FileSize ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Gets file size in bytes. Syntax FILESIZE filename,size Remark FILESIZE returns the length, in bytes, of the file specified by . Return If exist, is set to the file size and SUCCESS is set to TRUE; otherwise, SUCCESS is set to FALSE. See also Read, Seek Get ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Gets a string from remote system. Syntax GET s Remark GET collects a string, terminated by a carriage return, from the remote system. GET does not eliminate the BackSpace character [Ctrl H] from the input, therefore a CONCAT statement should be perform after the GET statement to eliminate the BackSpace character. Return contains the collected string. The ending carriage return is discarded. TELEMATE SCRIPT BUILT IN PROCEDURES 36 See also Clear COM, ComInCount, GetCh Example GET s ; get a string from remote system filename = "" ; prepare the variable CONCAT filename,s ; eliminate the BackSpace GetCh ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Gets a character from remote system. Syntax GETCH ch Remark GETCH gets a single character from the remote system. If no character is available, GETCH return immediately. GETCH statement, like the INKEY$ function in BASIC, does not wait. Return If a character is successfully read into , SUCCESS is set to TRUE; otherwise, SUCCESS is set to FALSE. See also Get Example REPEAT ; to wait for a character, GETCH ch ; repeat the GETCH until UNTIL SUCCESS ; a character is available HangUp ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function HangUps the modem. Syntax HANGUP Remark HANGUP sends the modem hangup string to modem. If the hangup string is the "^#" macro sequence, Telemate hangs up the modem by dropping DTR. Image ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Captures the terminal screen into an image file. Syntax IMAGE IMAGE filename TELEMATE SCRIPT BUILT IN PROCEDURES 37 Remark IMAGE captures the terminal screen into an image file by appending the screen to the file . If no is supplied, the last image filename is used. Input ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Reads a string from the keyboard. Syntax INPUT s Remark INPUT collects a string, terminated by a [Enter], from the keyboard. When the INPUT statement in the script is executed, the following input characters are placed in a keyboard buffer no matter if they are to be read or not. As a result, they NOT sent to the remote system automatically. It is important to give up the control of keyboard whenever no more keyboard input is needed using the CLEAR KEY statement. INPUT does not eliminate the BackSpace character [Ctrl H] from the input, therefore a CONCAT statement should be perform after the INPUT statement to elimate the BackSpace character. Return contains the collected string. The ending [Enter] is discarded. See also Clear Key, InputCh Example INPUT s ; get a string from remote system filename = "" ; prepare the variable CONCAT filename,s ; eliminate the BackSpace CLEAR KEY ; give up keyboard control such that ; following keys are sent to remote ; system automatically InputCh ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Reads a character from the keyboard. Syntax INPUTCH ch TELEMATE SCRIPT BUILT IN PROCEDURES 38 Remark INPUTCH gets a single character from the keyboard. If no character is available, INPUTCH returns immediately. INPUTCH statement, like the INKEY$ function in BASIC, does not wait. When the INPUTCH statement in the script is executed, the following input characters are placed in a keyboard buffer no matter if they are to be read or not. As a result, they are NOT sent to the remote system automatically. It is important to give up the control of keyboard whenever no more keyboard input is needed using the CLEAR KEY statement. Return If a character is successfully read into , SUCCESS is set to TRUE; otherwise, SUCCESS is set to FALSE. See also Clear Key, Input Example REPEAT ; to wait for a character, INPUTCH ch ; repeat the INPUTCH until UNTIL SUCCESS ; a character is available CLEAR KEY ; give up keyboard control such that ; following keys are sent to remote ; system automatically Itoa ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Converts an integer to a string. Syntax ITOA i,s Remark ITOA converts the integer to a string and store it into . Return contains the string representation of the value . See also Atoi Keystroke ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Simulates keystrokes. Syntax KEYSTROKE s TELEMATE SCRIPT BUILT IN PROCEDURES 39 Remark KEYSTROKES simulates keystrokes as if they are generated by the keyboard, including [Alt] keys. It is equivalent to the '^-' keystroke simulation macro, except that the string does not include the '^-' symbol. Example KEYSTROKE "`1200`2e00`1400`1900" ; generates [Alt E] [Alt C] [Alt T] [Alt P] which switch to the ; editor, copy the marked text to the clipboard, switch to the ; terminal and paste the content in the clipboard to the remote ; system. Length ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Calculates the length of a string. Syntax LENGTH s,len Return is the length of . If is an empty, is 0. LoadFon ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Loads a phone directory. Syntax LOADFON phoneDir Remark LOADFON loads the with extension .FON and the corresponding memo file .MEM into the dial window. If does not include a directory, the Telemate directory is used. The extension .FON can be omitted. Return Upon successful completion, SUCCESS is set to TRUE; if does not exist, SUCCESS is FALSE. See also Dial Example LOADFON "LONGDIST.FON" TELEMATE SCRIPT BUILT IN PROCEDURES 40 LoadKey ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Loads a keyboard definition table. Syntax LOADKEY keyTable Remark LOADKEY loads the with extension .KEY. If does not include a directory, the Telemate directory is used. The extension .KEY can be omitted. Return Upon successful completion, SUCCESS is set to TRUE; if does not exist, SUCCESS is FALSE. Example LOADKEY "EUROPE.KEY" LoadMac ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Loads a macro definition table. Syntax LOADMAC macroTable Remark LOADMAC loads the , with extension .MAC into the macro window. If does not include a directory, the Telemate directory is used. The extension .MAC can be omitted. Return Upon successful completion, SUCCESS is set to TRUE; if does not exist, SUCCESS is FALSE. Example LOADMAC "CIS.MAC" LoadPad ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Loads a keypad definition table. Syntax LOADPAD keypadTable TELEMATE SCRIPT BUILT IN PROCEDURES 41 Remark LOADPAD loads the , with extension .PAD into the macro window. If does not include a directory, the Telemate directory is used. The extension .PAD can be omitted. Return Upon successful completion, SUCCESS is set to TRUE; if does not exist, SUCCESS is FALSE. Example LOADPAD "VT102DEL.PAD" LogOff ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Closes the log file. Syntax LOGOFF Remark LOGOFF closes a previous opened log file. Return LOGGING is set to 0 (FALSE). See also LogOn, LogPause, LogResume LogOn ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Opens a log file and captures incoming data into the file. Syntax LOGON LOGON filename Remark LOGON opens the log file and starts capturing the incoming data into it. If is not supplied, the filename specified in the last LOGON statement is used. If there is no prevous LOGON statement, the one in the log file field of the phone directory is used. If this field is empty, "TM.LOG" is used. Return Upon successful completion, SUCCESS is set to TRUE and LOGGING is set to 1 (TRUE); otherwise, SUCCESS is 0 (FALSE). See also LogOff, LogPause, LogResume TELEMATE SCRIPT BUILT IN PROCEDURES 42 LogPause ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Pauses capturing incoming data into the log file. Syntax LOGPAUSE Remark LOGPAUSE pauses capturing incoming data. The LOGGING variable should be checked to determine if a log file open. A value of 1 indicates a log file is open. Return LOGGING is set to 2. See also LogOff, LogOn, LogResume LogResume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Resumes capturing incoming data into the log file. Syntax LOGRESUME Remark LOGRESUME resumes capturing incoming data. The LOGGING variable should be checked to determine if the log file is in pause. A value of 2 indicates the log file is in pause. Return LOGGING is set to 1. See also LogOff, LogOn, LogPause Open ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Opens a text file for reading or writing. Syntax OPEN filename Remark OPEN opens the text file for reading and writing and strip the ending EOF [Ctrl Z]. OPEN closes the previously open file automatically if no CLOSE command is issued to that file. Return Upon successful completion, SUCCESS is set to TRUE. If does not exist, SUCCESS is FALSE. See also Append, Close, Create, FileExist, FileSize, Read, Seek, Tell, Write TELEMATE SCRIPT BUILT IN PROCEDURES 43 Example OPEN "MYFILE" ; open the file "MYFILE" IF NOT SUCCESS ; report if not found PRINT "File not found." STOP ENDIF READ s ; read the first line PRINT s ; print it CLOSE ; close the file OPEN "FILE1" ; open FILE1 OPEN "FILE2" ; close FILE1 and open FILE2 Print ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Prints integers or strings to the terminal screen. Syntax PRINT PRINT s PRINT i PRINT s1,s2,i1,i2,s3, ... PRINT s1,s2,i1,i2,s3, ... , Remark PRINT outputs variables or constants of integer or string to the terminal screen. Each two arguments are separated by a comma. PRINT supplies a newline by default. If a comma follows, no newline is supplied. See also At, WhereX, WhereY Example PRINT "hello, world" ; say hello to everyone PRINT "hello, ", ; say that again PRINT "world", PRINT PRINT "x = ",x ; output multiple strings or integers PRINT "My name is ",firstName," ",lastName TELEMATE SCRIPT BUILT IN PROCEDURES 44 Put ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Sends strings or integers to the remote system. Syntax PUT PUT s PUT i PUT s1,s2,i1,i2,s3, ... PUT s1,s2,i1,i2,s3, ... , Remark Like the PRINT statement, PUT sends variables or constants of types integer or string to the remote system. Each two arguments are separated by a comma. Integers are converted to their string representation automatically before transmitting to the remote system. PUT supplies a carriage return [Ctrl M] by default. If a comma follows, no carriage return is supplied. Control characters can be sent by using the '^' prefix. For example, "^C" represents the [Ctrl C], "^M" the carriage return [Enter] and "^[" the Escape key [Esc]. The following macro sequences have special meanings. ^^ the character '^' ^~ the character '~' ~ pause 0.5 second ^# drop DTR signal to hangup modem ^% break signal ^$ memo field in phone directory ^& password field in phone directory ^* modem hangup string ^( modem init string ^) modem answer string See also Clear COM, ComOutCount, Waitfor Example PUT "first last" ; transmit first name and last name ; then a carriage return (^M) PUT "first ", ; same as above PUT "last", PUT PUT ; these two lines are PUT "^M", ; equivalent TELEMATE SCRIPT BUILT IN PROCEDURES 45 firstName = "first" ; set first and last name lastName = "last" password = "^&" ; use the password field in TM.FON PUT firstName," ",lastName,"^M~~~~",password ; send name, [Enter], wait for 2 seconds then send ; the password, [Enter] PUT "~^#~~^)", ; wait 0.5 second, drop DTR, ; wait 1 second, then sends the ; modem answer string Query ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Function Queries option value. Syntax QUERY