Script syntax
Create new 3270 or 5250 session scripts using the Manage Scripts feature that is available from the terminal view.
A script is a program made up of function definitions, variable definitions, and executable program statements. The terminal emulator scripting language is similar to Java™ or C. The scripting language has these general conventions:
- Keywords, variables and function names are case-insensitive
- All statements are terminated with a semi-colon
- Multiple statements can appear on a single line
- Function definitions must appear ahead of the data declarations and program statements
- Declarations can appear anywhere before they are referenced
The general layout is:
Return-type FUNCTION function-name (optional parameters) {optional local variables; statements...}
- Reserved words
- Reserved words are character strings that have special meanings. They cannot be used except for their intended meaning. The reserved words are of three types:
- Language keywords
- Language keywords are used as commands within a script. They are
interpreted to provide some action or considered as part of a statement.
You can use these keywords only for their predefined purpose:
Item 1 Item 2 Item 3 AND ; (semicolon) If OR Break Int EQ Continue Real NE Else Return GE Exit String GT For While LE Function LT - Declarations and function names
- Each script program begins with global data declarations, stating the global variables and user-defined functions you will be using. Declarations build an association between a function and its attributes or values. You do not need to declare any of the built-in functions, because the interpreter already recognizes these function names.
- Identifiers
- Identifiers are the names that you create to denote constants,
variables, and functions. Identifiers have the following characteristics:
- an identifier can be any length
- the first character must be alphabetic (a-z, A-Z), numeric (0-9), or an underscore (_)
- the remaining characters can be alphabetic (a-z, A-Z), numeric (0-9), or underscores (_)
- each identifier must be unique. Identifiers cannot be one of the reserved words.
- Punctuation
- The following punctuation rules apply to a section
- Statements end with a semi-colon – ;
- Parameter lists are enclosed in parenthesis – ()
- Parameters are separated by commas – ,
- Statement blocks are enclosed in braces – {}
- Embedded quoted strings
- String literals are enclosed in double quotation marks or single
quotation marks. You can insert double quotation marks as part of
a string literal by preceding the quotation marks with the escape
character /". Alternatively, you can begin and end the string literal
with the single quotation mark character '. To imbed a single quotation
mark use the /' escape sequence or enclose the string literal within
double quotation marks. Example:
// Both statements yield embedded quotation marks quotedStr1 = "The job /"TSOA/" is running"; quotedStr2 = 'The job "TSOA" is running'; - White space
- The script language ignores white space (spaces, tabs, new-lines) except within a quoted string.
- Comments
- Comments are supported as a way to add explanatory text to your
script program or to exclude certain parts of the code.
- comments can be single line or multi-line comment blocks
- the script interpreter ignores comments
- comment blocks are enclosed within the /* */ pairs. Comment blocks can span multiple lines.
- comments can also start with the // character string. The interpreter ignores everything to the right of the double slash up to the end of the line (new-line character).
- comments can start anywhere in the script
Example:// This is a single line comment a = 3; // this is a comment /* This section defines multiple line comment block */ a = 3; /* imbedded comment block */ b=4;