The script language has four types of variables: built-in variables, Windows environment variables, local variables and global variables.
Built-in Variables
Built-in variables are predefined. All built-in variables start with a dollar sign ($) and are all upper case. The following built-in variables are available.
$CLIPBOARD |
replaced by any text on the Windows clipboard. |
||||||||||
$COLS |
replaced by the number of screen columns. |
||||||||||
$COMPUTERNAME |
computer name. |
||||||||||
$CONVERT(screen_position, |
returns the row or column for the given screen position. |
||||||||||
$CONVERT(row,col,POS) |
returns the screen position relative to 1 for the given row and column. |
||||||||||
$CRLF |
replaced by a carriage return and line feed. |
||||||||||
$CURSOR |
replaced by the cursor position on the screen relative to 1 (row 1 column 1). |
||||||||||
$DATE |
date in the local date format. |
||||||||||
$DATEDMY |
date in DD/MM/YYYY format. |
||||||||||
$DATEMDY |
date in MM/DD/YYYY format. |
||||||||||
$DATEYMD |
date in YYYY-MM-DD format. |
||||||||||
$FILEERROR |
the return code of the last script file I/O operation. |
||||||||||
$FILESTAT(file_path, |
Returns an integer which is the status returned from an open request on the file. The file_mode should be one of the following: modeRead The returned integer will be one of the following standard Windows file exceptions: 0 = none. No error occurred. If $FILESTAT("D:\test.txt",modeRead),EQ,2,FileNotFound: |
||||||||||
$LEFT(string,length) |
Returns the specified number of characters from the left side of the string. Use this variable to extract characters from a string or another variable. string and/or length may be a variable. |
||||||||||
$LEN(string) |
Returns the length of the string. string may be a variable. |
||||||||||
$LONGDATE |
date in local long date format. |
||||||||||
$MID(string,start[,length]) |
Returns the specified number of characters from the string starting with the character number specified in the start parameter. string, start and/or length may be a variable. |
||||||||||
$OIA |
replaced by the text in the Operator Information Area line on the terminal screen |
||||||||||
$RIGHT(string,length) |
Returns the specified number of characters from the right side of the string. Use this variable to extract characters from a string or another variable. string and/or length may be a variable. |
||||||||||
$ROWS |
replaced by the number of screen rows. |
||||||||||
$SCREEN[(start[,length])] |
replaced by the text at the specified location on the terminal screen. where:
start and/or length may be a variable. The ((start[,length])) parameter is optional. If you specify "$SCREEN" with no parameter, it is replaced by the text contents of the entire screen. If the(start[,length]) parameter is invalid, no substitution will take place and the variable will be treated as a literal.
|
||||||||||
$SCREEN[(top,left,bottom,right[,RECT])] |
replaced by the text at the specified location on the terminal screen. where:
top, left, bottom, right and/or RECT may be a variable. The (top,left,bottom,right) parameter is optional. If you specify "$SCREEN" with no parameter, the variable is replaced by the text contents of the entire screen. If the (top,left,bottom,right) parameter is invalid, no substitution will take place and the variable will be treated as a literal. |
||||||||||
|
|||||||||||
$SCREEN[(top,left,length)] |
replaced by the text at the specified location on the terminal screen. where:
top, left and/or length may be a variable. The (top,left,length) parameter is optional. If you specify "$SCREEN" with no parameter, the variable is replaced by the text contents of the entire screen. If the (top,left,length) parameter is invalid, no substitution will take place and the variable will be treated as a literal. |
||||||||||
$TIME |
time in local time format. |
||||||||||
$USERNAME |
current logged on user name. |
Windows Environment Variables
Windows environment variables can be used in script strings. Windows environment variables are enclosed in % signs and may be in upper or lower case. For example:
type "%COMPUTERNAME%"
Local Variables
Local variable names start with a dollar sign ($) and may be mixed case. Local variables are created dynamically by the AskFor and SetVar script commands which read text into a variable. Here are a couple of examples:
AskFor "Enter your userid and click OK",$NAME
SetVar $NAME,"Sam Spade"
Most script commands accept a variable in place of literal data. The text contained in the variable is substituted for the variable when the script command is processed.
Global Variables
Global variable use the same syntax as a local variable. The variable name must start with a dollar sign ($) and may be mixed case. Global variables must be declared using the Global script command. The data in global variables is available within scripts called using the include script command. Local variables are not available to scripts called using the include command.
Variable Substring
You can extract a substring from a local variable, global variable or the built-in variable using the following format:
$variable[(start[,length])]
where:
start | is the starting position within the variable. |
length | is the number of characters to include. length defaults to 1 if it is not specified. |
start and/or length may be a variable.
For example, the following script types Joh on the screen.
SetVar $TEST,"John Doe"
type $TEST(1,3)
exit
Concatenated Variable Names
You can concatenate variable names. For example, $$SCREEN(1,4)$SCREEN(10,3) would result in a variable name $ followed by the contents of screen location 1-4 followed by the contents of screen location 10-12. Thus, if screen location 1-4 contained "WHIZ" and screen location 10-12 contained "KID" the result would be a variable name of "$WHIZKID".
See Also:
TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.