Network-Level self-checking scripts
Although the message-level IF statement is a fundamental part of
self-checking scripts, you can code network-level IF statements to
enhance the self-checking qualities of your scripts further and to
reduce the size of the TEXT-IF-WAIT blocks in your message generation
decks, as shown in the following example
NET1 NTWRK
* Sample WSim Script
* This script illustrates using network IF statements to reduce the
* size of message generation decks.
*
* Beginning of NET1.
SEND IF LOC=D+0,TEXT=(ANYTHING),
THEN=WAIT,ELSE=WAIT,
WHEN=OUT
RECV IF LOC=D+0,TEXT=RESP,
SCAN=YES,THEN=CONT,
ELSE=CERROR,WHEN=IN
.
. Network definition statements.
.
DECK1 MSGTXT
* Beginning of DECK1.
MSG1 TEXT (MESSAGE 1), Defines MSG1.
RESP=(REPLY 1)
MSG2 TEXT (MESSAGE 2), Defines MSG2.
RESP=(REPLY 2)
.
. Message generation statements.
.
ENDTXT End of DECK1.
ERROR MSGTXT
* Beginning of ERROR deck.
WTO (EXPECTED RESPONSE ),
(NOT RECEIVED. ),
(PLEASE HELP!) Message to operator.
WAIT1 WAIT
ENDTXT End of ERROR deck.
WSim evaluates network-level IF statements SEND and RECV for every message sent and received by all terminals in the network. The following steps describe the sequence of events in message generation for the preceding example:
Steps:
- When WSim sends MSG1, IF statement SEND puts the terminal into a wait state. The RESP=(REPLY 1) operand on the TEXT statement indicates the expected response to this request.
- The terminal waits until WSim receives a message.
- IF statement RECV checks the message received and determines if the expected response REPLY 1 exists anywhere in the data stream. If so, THEN=CONT resets the WAIT indicator and enables the terminal to continue and send MSG2.
- If the expected response did not exist in the message received, IF statement RECV causes WSim to take the ELSE=CERROR action. CERROR specifies that WSim calls (C) the message generation deck named ERROR. This message generation deck notifies the operator that WSim did not receive the expected response. In fact, you could have set up this message generation deck to perform various error recovery actions, relieving the operator of manual intervention.