Using the Scripting Language (Release 3.6 and above)

Return to Introduction  Previous page  Next page

The TN3270 Plus scripting language is designed to automate common tasks and keystroke sequences. Each day the same keystrokes are entered over and over again. By creating a script, common sequences of keystrokes can be stored in a file. When the script file is run, the keystrokes are entered automatically.

 

Here are some common uses for scripts:

 

Connecting terminal emulation sessions.

 

Logging on terminal emulation users.

 

Transferring files from the PC to the Host or from the Host to the PC.

 

Performing a series of commonly issued commands.

 

A script file is a text file (.txt) that contains script commands. A script simulates the activities of a user at the keyboard. The script file can be created using your favorite word processor or text editor. Any application than can create a standard text (.txt) file will work.

 

Script Language Syntax Definition

The syntax descriptions of the script commands use the following notational conventions:

1.Magenta colored words are replaced by user input.
2.Blue colored symbols are part of the syntax definition and are not included in the command.
3.The following symbols are part of the command and should be entered exactly as they appear in the command format:

,        comma

:        colon

"        double quotation marks

()        Parentheses

4.Square brackets [ ] indicate an optional parameter and are not included in the command.
5.Braces { } are used with the vertical bar | to indicate choices between two or more mutually exclusive items and are not included in the command.
6.Words starting with a dollar sign $ are variables. Variable names are case sensitive.
7.Words starting in column one and ending with a colon : are labels. Label names are case sensitive.
8.An ellipsis indicates that the same pattern continues.
9.Lines starting with an single quote (') are treated as comments.

 

Each line in a script file contains a command in the following format:

 

[lvariable =] command( [parameter1[,parameter2,parameter3,...parametern]])                

 

The command indicates the function to perform and the parameter(s) provide the data needed for the function.  Parameters containing embedded blanks or commas must be enclosed in double quotation marks. Parameters may be split across multiple lines. An underscore (_)  indicates more parameters on the next line. For example,

 

MsgBox("This is a test of the continuation _        

       character")        

 

The command is not case sensitive, so it may appear in any combination of upper and lower case. Any blanks or tabs between the command and the first parameter are ignored.

 

Comment lines can be added to a script file by placing an single quote followed by the comment. For example:

 

' -------------------------------------------------------------------

' These three lines are comments

' -------------------------------------------------------------------

MsgBox("Hello World")  ' This is also a comment

 
Comments cannot be included on a line that contains a continuation.

 
The Script Commands section contains a complete list of script commands. The syntax of each command is presented along with examples for using the command.

 

Creating Your First Script

The following steps will lead you through the creation of your first script:

 

1.Create a new text file in the TN3270 Plus directory using you favorite word processor or text editor.

 

2.Type the following lines:
 

' This is a comment. -- My first script file.

type("this is a test")

key(enter)

exit

 

3.Save this script as a text file named "test.txt" in the TN3270 Plus directory. Your first script is now complete.

 

Running Your First Script

The following steps will lead you through running your first script:

 

1.Connect a TN3270 Plus session.
2.Logon to your userid.
3.Open the Host menu and select Run Script... and click on the Browse… button.
4.In the Select Script File dialog box, click on "test.txt" and then click on the Open button.
5."this is a test" is typed on your screen and then "entered" (pressing the enter key is simulated by the script). The result of this script is the same as if you typed "this is a test" on the keyboard and pressed the enter key.

 

For an example of a logon script, see the Sample Logon Script.

 


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.