
RUNTNSCR 

RUNTNSCR is a utility for running scripts using the TNAPI API to send and receive data in a telnet session. 
In order to use RUNTNSCR you must have TNAPI installed. 
There are two components to RUNTNSCR:  RUNTNSCR.CMD which is the command and RUNTNSCR.RPG which is the RPG program.

Scripts are created in a source file. The default name is QTNSCRIPT but any source file can be used. 
RUNTNSCR will read each line in the script and execute it.

To run a script, enter RUNTNSCR and prompt it (F4)

Enter the following parameters:

User ID  The user ID to use on the target system. If it is the same as the current one you can leave the default to *CURRENT.

Password  The password to use on the target system. The password will not be displayed or shown in the log.

System name  The system name to connect to. The default is the current system or LOOPBACK.

Script file and library  The source file where the script is stored

Member  The member name where the script file is stored.

Log file  The name of the file to contain the screens returned by TNAPI. 
           This must be a flat file of 80 bytes. Specify *NONE if you do not want screen logging.

Display screens  Display the screens as they appear. This is for interactive jobs only.

Clear log  Clear the screen log before starting. Specify *YES or *NO

Printing:  Errors are logged to a print file named QSYSPRT, along with the line the error occurred on.
           If you want all source lines printed, specify *ALL.

Parameters: Enter up to 10 parameters that will be sent during the script execution.

 
RUNTNSCR script language

Each line contains a command, at least one space, and one or more parameters, with the exception of blanks lines, 
comment lines (which start with /) or label lines (see below). The case of the command is ignored; however any text stings 
should be enclosed in quotes (single or double).
Any data sent to the screen can include embedded control codes. 

The documentation for TNAPI contains a list of valid control codes.

Review RUNTNSCR.SCR for examples of scripts


Labels 
Labels can be used in the script as a location to branch to.
All labels start with @ and must be on a line by themselves. The case is ignored and only the first 10 characters are used.  

Example:

@GoodMenu
@SignOff 



Valid RUNTNSCR commands

SNDDTA  string
Send the string to the screen at the current location and send the ENTER key
Example:
SNDDTA  go mymenu


DATA  string
Send data to the screen but do not send ENTER 
Example: 
DATA 10796%TB33 Main street


SEND functionkey
Send a function key to the screen (do not enclose with quotes). This can include special function codes.
See the TNAPI documentation for the list of special codes.

Examples: 
SEND ENTER
SEND F3
SEND  GETDTA


SNDPRM number
Send one of the 10 parms that were entered on the command but do not send a function key.

Example: 
SNDPRM 3
SNDPRM 10

 
POSCSR RR,CC
Position the cursor to the specified row and column. Note: the row and column must be two digits each.

Example;
POSCSR 03,04


GOTO label
Start execution at the line containing the specified label

Example;
GOTO GoodMenu


COMPARE rr,cc string
Compare the contents of the screen at the specified location with the string. RR,CC is the row and column where the screen text is 
located and must be two digits each. The length of the compare is determined by the length of the string.

Example:
COMPARE 01,34   A/R Menu
COMPARE 24,10  F3=


IFxx  label
Branch after comparison. This command is used after a COMPARE statement. Valid comparisons: IFEQ, IFNE, IFGT, IFLT, IFGE, IFLE. 
The IFxx command does not need to directly follow the COMPARE command. The comparison values are retained until another COMPARE command, 
even if the screens have changed.

Examples:
IFEQ GoodMenu
IFNE Signoff
 

PAUSE seconds
Pause a specified number of seconds 

Example: 
PAUSE  10


WAITTIME seconds
Specify the number of seconds that TNAPI will wait before returning a timeout error; up to 5 digits with 2  decimal places. 
The default is 30 seconds

Example:
WAITTIME  120


ONERROR action
Specify what action to take if a screen error is detected, such as no response from the target system. Valid actions are *END or a label. 
The ONERROR command can be anywhere in the script but the action is not set until the command is executed.

Example: 
ONERROR *END
ONERROR PrtMsg


KBDLCK action
This is the action to take if the keyboard is locked.  The default is *IGNORE. 

*IGNORE  ignore the error and continue.
*RESET  Send an error reset function key. RUNTNSCR will try sending error reset up to 10 times. 
         If the error doesnt clear then the *EOJ action is taken.
*ERROR  Take the action specified by the ONERROR command
*END  End the run
Label  a label to branch to.

Example:
KBDLCK *RESET
KBDLCK *END
KBDLCK PrtLckMsg


ERRMSG string
Print the message in the error log. 


Example:
ERRMSG Unknown error occurred


SETWAIT RR,CC string
AND RR,CC string
OR RR,CC string
The SETWAIT, And, and OR commands are used to set the wait parameters for TNAPI. Review the documentation for TNAPI to see how the wait function works.


END
End the run








