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.
$ARG0 |
full path of the script file from the command line. |
||||||||||
$ARG1, ARG2, ... |
arguments from the command line. |
||||||||||
$ARGC |
count of arguments on the command line. |
||||||||||
$CLIPBOARD |
replaced by any text on the Windows clipboard. |
||||||||||
$COLS |
replaced by the number of screen columns. |
||||||||||
$COMPUTERNAME |
computer name. |
||||||||||
$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. |
||||||||||
$LONGDATE |
date in local long date format. |
||||||||||
$OIA |
replaced by the text in the Operator Information Area line on the terminal screen |
||||||||||
$PARENTSCRIPT |
name of the calling script or "<none>". |
||||||||||
$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. |
||||||||||
$SCRIPTFOLDER |
the full path of the folder containing the currently active script. |
||||||||||
$SCRIPTNAME |
name of currently active script. |
||||||||||
$SESSIONNAME |
name of session the script is running in or "<none>". |
||||||||||
$TIME |
time in local time format. |
||||||||||
$USERNAME |
current logged on user name. |
||||||||||
$VERSION |
The TN3270 Plus version number as an integer. For example release 3.6.0 = 3600 and release 3.6.1 = 3601. |
Sample Script
' -------------------------------------------
' Display Script Variables
' -------------------------------------------
MsgBox(_
"ARGC = " & chr(9) & $ARGC & $CRLF & _
"$COLS = " & chr(9)& $COLS & $CRLF & _
"$COMPUTERNAME = " & $COMPUTERNAME & $CRLF & _
"$CURSOR = " & chr(9)& $CURSOR & $CRLF & _
"$DATE = " & chr(9)& $DATE & $CRLF & _
"$FILEERROR = " & chr(9)& $FILEERROR & $CRLF & _
"$LONGDATE = " & chr(9)& $LONGDATE & $CRLF & _
"$OIA = " & chr(9)& $OIA & $CRLF & _
"PARENTSCRIPT = " & chr(9)& $PARENTSCRIPT & $CRLF & _
"ROWS = " & chr(9)& $ROWS & $CRLF & _
"SCREEN(1,20) = " & chr(9)& $SCREEN(1,20) & $CRLF & _
"$SCRIPTFOLDER = " & chr(9)& $SCRIPTFOLDER & $CRLF & _
"$SCRIPTNAME = " & chr(9)& $SCRIPTNAME & $CRLF & _
"$SESSIONNAME = " & chr(9)& $SESSIONNAME & $CRLF & _
"$TIME = " & chr(9)& $TIME & $CRLF & _
"$USERNAME = " & chr(9)& $USERNAME & $CRLF & _
"$VERSION = " & chr(9)& $VERSION & $CRLF &_
)
exit
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%)
Windows User Environment Variables
Windows user environment variables can be used in script strings. Windows user environment variables are enclosed in % signs and may be in upper or lower case. Windows user environment variables can be created with the TN3270 Plus script SetUserEnv command. Windows User Environment Variables are accessible from the programs external to TN3270 Plus like Windows PowerShell or VBScript.
Local Environment Variables
Local Environment variables can be used in script strings. Local environment variables are enclosed in % signs and may be in upper or lower case. Local environment variables can be created with the TN3270 Plus script SetEnv command. Use Local Environment Variables to pass data from one TN3270 Plus script to another.
Local Variables
Local variable names start with a dollar sign ($) and may be mixed case. Local variables are created dynamically by an assignment statement. For example:
$Name = AskFor("Enter your userid and click OK")
$CursorRow = Convert($Cursor,ROW)
$CursorColumn = Convert($Cursor,COL)
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.
$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.