Scripting in MacComCenter Smith Micro Software Scripts are text files that allow you to automate data connections. With the scripting language provided in the OEM products, you typically would use it to automate the logon process only. However, you can also create simple scripts to help control the flow of data. Scripts are to be created in text editors only, such as Teach Text, Simple Text or even MacComCenter's QuickView Editor. Scripts can be run by one of three ways: 1. Placing them in one of the Macro keys with the Script box checked 2. Pulling down the Connect menu and selecting Run Script 3. Using the data phone list to dial the number and including an associated script to continue the process after connection A MacComCenter script is based on the C programming language and must be in the following basic format: /* Sample Script 1 */ main() { Script Command Line 1; Script Command Line 2; ... } The /* and */ are used for comments. The command "main()" must always begin a script in MacComCenter. It must then be followed by an open curly bracket "{". Then after all the script commands are done, it must end with a close curly bracket "}". There are two basic scripting commands: the In statement and the Out statement. The In statement is used to suspend the script until you get to a particular prompt within the data connection. The Out statement is then used to output a given string in response to that prompt. As can be seen, most scripts will consist of a series of In and Out statements to control the logon sequence. Other script commands can be used to automate the settings for a session as well as to help control the flow. The syntax of the In Statement is: In("xxxx",n); The xxxx is the last few characters of the prompt you're looking for while the n is the amount of time, in seconds, for the script to wait for the prompt. The syntax of the Out statement is: Out("xxxx"); The xxxx is the string of characters to be sent to the remote location. You can use any character found on a standard keyboard as well as a Return (\r) and ASCII character. The ASCII characters are represented by their hexadecimal equivalent and preceded by a backslash (\x). For example, to send an Escape code, you would use \x1B. The ASCII character table is typically located at the back of our manuals. Below is a sample script that might log you on to a local BBS: main() { CLS(); /*clears the terminal screen*/ Echo("Sample script to log on to XYZ BBS\r\n"); /*prints message to screen*/ /*These are optional*/ Baud(57600); /*sets the current baud rate*/ Data(8); /*sets the current data bits*/ Parity(N); /*sets the current parity*/ Stop("1"); /*sets the current stop bits*/ LocalEcho(0); /*toggles Local Echo*/ RtsCts("ON"); /*toggles Rts/Cts flow control*/ XonXoff("OFF"); /*toggles Xon/Xoff flow control*/ /*Main part of script*/ Dial("xxx-xxxx"); /*dials the given number*/ In("=yes?",20); /*waits 20 seconds for the string: =yes?.*/ Out("y\r"); /*outputs a y and a carriage return (\r) */ In("first name?",20); /*waits 20 seconds for the string: first name? */ Out("John\r"); /*outputs the proper response with a carriage return*/ In("last name?",20); /*waits 20 seconds for the string: last name? */ Out("Doe\r"); /*etc... */ In("password?",20); /*etc... */ Out("********\r"); /*etc... */ } ______________________________________________________________________ You can also use the Wait command to have the script wait a given number of seconds before outputting a string. The following is a modification of the above script using the Wait commands instead of In statements: /*Main part of script*/ Dial("xxx-xxxx"); /*In("=yes?",20);*/ Wait(5); Out("y\r"); /*In("first name?",20);*/ Wait(5); Out("John\r"); /*In("last name?",20);*/ Wait(5); Out("Doe\r"); /*In("password?",20);*/ Wait(5); Out("********\r");