Example of a script

Below shows an example of a script that contains a network definition and several message generation decks. This script defines a simple network in which WSim simulates a single logical unit (LU) representing a VTAM® application. WSim uses basic message generation decks to log the LU onto TSO and log it off again.

Figure 1 shows how to write the script in the WSim scripting language and Figure 2 shows how to write the same script in STL. For more information on coding scripts in STL, refer to WSim Script Guide and Reference.

Later chapters in this book explain the statements used to define this network. Introducing message generation decks explains the statements used in the message generation decks and describes how WSim processes the decks and how they interact with the network definition. For now, note the relationship between the network definition, which starts with the NTWRK statement, and the message generation decks, which start with MSGTXT statements and end with ENDTXT statements. The network definition is always placed at the beginning of a script. It contains statements that specify characteristics for the entire network and definitions of individual devices within the network. The statements immediately following the NTWRK statement specify the characteristics for the entire network. Within the definitions for individual devices, more characteristics can be specified to further define the devices or to override values specified for the network. The message generation decks follow the network definition. A script can contain any number of message generation decks. Through network definition statements and message generation statements, you control the sequence in which the message generation decks are used by the simulated devices.

In this example, the order of message generation decks that WSim follows is specified by the PATH statement. The first message generation deck, INITSESS, logs the LU on to TSO, which is using the application ID TSO01. This message generation deck checks to see if the LU enters ISPF after successfully logging on. If it does, WSim proceeds to the next message generation deck, LOGOFF, specified by the PATH statement. If the LU does not enter ISPF, WSim calls another message generation deck, ISPFDECK, to invoke ISPF. WSim then uses the message generation deck LOGOFF to log the LU off TSO. WSim uses the message generation deck CLEAR to clear the screen any time the characters "X'1DC8'***" appear in the request unit (RU+0).
Figure 1. Sample script in WSim scripting language
SAMP1    NTWRK     HEAD='Sample Network 1',  Heading for interval reports.
                   UTI=100,                  Network user time interval.
                   MSGTRACE=YES,             Logs MTRC records.
                   BUFSIZE=5000              5000-byte buffer for LU.

****************************************************************************
*                       Sample WSim Script                                 *
*   The following script defines a simple network in which WSim            *
*   simulates a single LU (SLU) representing a locally attached 3270       *
*   terminal.  WSim uses three message generation decks to log the LU onto *
*   TSO and then off again.                                                *
****************************************************************************
*   Coding for network named SAMP1:
*
NETIF    IF        LOC=RU+0,
                   TEXT=('1DC8'***),         Defines logic test for messages
                   THEN=CCLEAR,WHEN=IN,      received from the system under
                   SCAN=YES                  test.
*
SIMPLE   PATH      INITSESS,LOGOFF           Specifies the sequence in which
*                                            WSim processes message decks
*                                            named INITSESS and LOGOFF.
*
WSIMAPPL VTAMAPPL                            Defines VTAM application named
*                                            WSIMAPPL.
SLU      LU        MAXSESS=(0,001),          Defines one secondary half
                   INIT=SEC,                 session for SLU.  Specifies
                   LUTYPE=LU2,               LU type and the name of a VTAM
                   DLOGMOD=D4A32782,         logon mode table entry, delays
                   THKTIME=UNLOCK,           start of intermessage delays,
                   LOGDSPLY=BOTH             and specifies that display
*                                            buffers are written to the
*                                            log data set.
*
INITSESS MSGTXT
****************************************************************************
*   INITSESS deck simulates SLU logging on to TSO.  In this deck, the TSO  *
*   resource name is TSO01, the user ID is ID02 and the password is PW02.  *
****************************************************************************
*
*                                            Beginning of INITSESS.
WTO1     WTO       (STARTING $MSGTXTID$)     Message to operator console.
CMND1    CMND      COMMAND=INIT,             Initiates session.
                   RESOURCE=TSO01
0        IF        LOC=RU+0,                 Tests for characters ENTER
                   TEXT=(ENTER USERID),      USERID.
                   SCAN=YES,THEN=B-MSG1
WAIT1    WAIT
         BRANCH    LABEL=WAIT1               In case bind resets the wait.
*                                            Interrupts message generation.
MSG1     TEXT      (ID02)                    Enters user ID ID02.
WTO2     WTO       (Logging on TSO as ),     Message to operator console.
                   (ID02)
ENTER1   ENTER                               Sets ENTER AID byte.
0        IF        LOC=RU+0,                 Tests for characters ENTER
                   TEXT=(ENTER LOGON),       LOGON.
                   SCAN=YES,THEN=CONT
WAIT2    WAIT
*                                            Interrupts message generation.
MSG2     TEXT      (PW02)                    Enters user password PW02.
ENTER2   ENTER                               Sets ENTER AID byte.
0        IF        LOC=RU+0,                 Tests for characters ISPF/PDF
                   TEXT=(ISPF/PDF ),         PRIMARY.
                   (PRIMARY),SCAN=YES,
                   THEN=CONT
1        IF        LOC=RU+0,TEXT=(READY),    Tests for characters READY
                   SCAN=YES,THEN=CISPFDECK   and calls ISPFDECK to invoke
*                                            ISPF.
WAIT3    WAIT
*                                            Interrupts message generation.
WTO3     WTO       (Logged on and ),         Message to operator console.
                   (received ISPF Primary ),
                   (Menu)
         ENDTXT                              End of INITSESS.
*
ISPFDECK MSGTXT
****************************************************************************
*   ISPFDECK simulates SLU accessing ISPF and waiting for the ISPF         *
*   primary menu to be returned before continuing message generation.      *
****************************************************************************
*
*                                            Beginning of ISPFDECK.
WTO1     WTO       (STARTING $MSGTXTID$)     Message to operator console.
MSG1     TEXT      (ISPF)                    Enters ISPF.
ENTER1   ENTER                               Sets ENTER AID byte.
0        IF        LOC=RU+0,                 Tests for characters ISPF/PDF
                   TEXT=(ISPF/PDF ),         PRIMARY.
                   (PRIMARY),SCAN=YES,
                   THEN=CONT
WAIT1    WAIT
*                                            Interrupts message generation.
WTO1     WTO       (Logged on and ),         Message to operator console
                   (received ),
                   (ISPF Primary Menu)
         ENDTXT                              End of ISPFDECK.
*
LOGOFF  MSGTXT
****************************************************************************
*   The following message generation deck exits ISPF and logs the LU       *
*   off TSO.                                                               *
****************************************************************************
*
*                                           Beginning of LOGOFF.
WTO1    WTO       (Starting $MSGTXTID$)     Message to operator console.
MSG1    TEXT      (X)                       Type X to exit ISPF.
0       IF        LOC=RU+0,TEXT=(READY),    Tests for characters READY.
                  SCAN=YES,THEN=CONT
WAIT1   WAIT
*                                           Interrupts message generation.
MSG2    TEXT      (LOGOFF)                  Enter text LOGOFF.
WTO2    WTO       (Logged off TSO)          Message to operator console.
ENTER1  ENTER
*                                           Interrupts message generation.
OPCMND1 OPCMND    (ZEND)                    Specifies the operator
WAIT2   WAIT                                command ZEND to end WSim execution.
        ENDTXT                              End of LOGOFF.
*
CLEAR   MSGTXT
****************************************************************************
*   WSim calls the following message generation deck to clear the screen   *
*   when *** appears in the request unit (RU+0).                           *
****************************************************************************
*
*                                           Beginning of CLEAR.
CLEAR1  CLEAR                               Clears the screen.
        ENDTXT                              End of CLEAR.
Figure 2. Sample script in STL
@network
************************************************************************
*                       Sample WSim Script                             *
*   The following script defines a simple network in which WSim        *
*   simulates a single LU (SLU) representing a locally attached 3270   *
*   terminal.  The three procedures are used by WSim to log the LU     *
*   onto TSO and then off again.                                       *
************************************************************************
*   Coding for network named SAMP1:
samp1    ntwrk    head='Sample Network 1',  Heading for interval reports
                  uti=100,                  Network user time interval.
                  msgtrace=yes,             Logs MTRC records.
                  bufsize=5000              5000-byte buffer for LU.
netif    if       loc=ru+0,
                  text=('1dc8'***),         Defines logic test for
                  then=cclearkey,when=in,   messages received from the
                  scan=yes                  system under test.
*
simple   path     initsess,logoff           Specifies the sequence in
*                                           which WSim processes message
*                                           decks named INITSESS and
*                                           LOGOFF.
*
cmm1     vtamappl
*                                           Defines VTAM application
*                                           named WSIMAPPL.
*
slu      lu       maxsess=(0,001),          Defines one secondary half
                  init=sec,                 session for SLU. Specifies
                  lutype=lu2,               LU type and the name of a
                  dlogmod=d4a32782,         VTAM logon mode table
                  thktime=unlock,           entry, delays start of
                  logdsply=both             intermessage delays, and
*                                           specifies that display
*                                           buffers are written to the
*                                           log data set.
@endnetwork
/*********************************************************************/
/*   INITSESS simulates SLU logging on to TSO.  In this procedure,   */
/*   the TSO resource name is TSO01, the user ID is ID02 and         */
/*   the password is PW02.                                           */
/*********************************************************************/
initsess:   msgtxt
            say 'STARTING' msgtxtid()
onin1:      onin index(RU,'ENTER USERID') > 0 then found = on
            found = off
            initself('TSO01')
            do while found = off
             wait until onin
            end
            deact onin1
            type 'ID02'
            say 'Logging on TSO as ID02'
            transmit using enter,
             and wait until onin index(RU,'ENTER LOGON') > 0
            type 'PW02'
onin2:      onin index(RU,'READY') > 0 then call ispfdeck
            transmit using enter,
             and wait until onin index(RU,'ISPF/PDF PRIMARY') > 0
            deact onin2
            say 'Logged on and received ISPF Primary Menu'
            endtxt
/*********************************************************************/
/*   ISPFDECK simulates SLU accessing ISPF and waiting for the ISPF  */
/*   primary menu to be returned before continuing message           */
/*   generation.                                                     */
/*********************************************************************/
ispfdeck:   msgtxt
            say 'STARTING 'msgtxtid()
            type 'ISPF'
            transmit using enter,
             and wait until onin index(RU,'ISPF/PDF PRIMARY') > 0
            say 'Logged on and received ISPF Primary Menu'
            endtxt
/*********************************************************************/
/*   LOGOFF exits ISPF and logs the LU off TSO.                      */
/*********************************************************************/
logoff:     msgtxt
            say 'Starting 'msgtxtid()
            type 'X'
            transmit using enter,
             and wait until onin index(RU,'READY') > 0
            type 'LOGOFF'
            transmit using enter
            say 'Logged off TSO'
            opcmnd 'zend'
            wait
            endtxt
/*********************************************************************/
/*   CLEARKEY simulates a user hitting the clear key.                */
/*********************************************************************/
clearkey:   msgtxt
            transmit using clear
            endtxt