CANCEL


CANCEL  {event_tag}
        {DELAY}
        {SUSPEND}

Where

event_tag is a string expression that specifies the "tag" value assigned to a POST, QSIGNAL, RESET, or SIGNAL statement. If the event_tag is a string constant expression, it must be 1 to 8 alphanumeric characters and enclosed in single or double quotes. (Strings containing hexadecimal constants are exempt from this restriction.) If you specify a nonconstant string expression, the first 8 characters of the string are used. If the string is shorter than 8 characters, the available characters are used. To satisfy conditions using event names, the first 8 characters must match exactly. If you specify a string variable, it cannot be the name of one of the reserved variables (for example, BUFFER).

Function

When you use the DELAY or SUSPEND arguments, the CANCEL statement is an asynchronous subset statement. When encountered on an ONIN, ONOUT, or ON SIGNALED statement, CANCEL causes the current delay between messages or the current suspension interval to be canceled.

The STL Translator handles CANCEL DELAY and CANCEL SUSPEND identically. Therefore, either asynchronous subset statement will cancel the current delay interval, if one is in effect, or will cancel the current suspension interval, if one is in effect, regardless of which argument you specify.

This statement also enables you to cancel an action specified by a POST, QSIGNAL, RESET, or SIGNAL statement if a time interval was specified and the interval has not expired. The event can only be canceled by the same resource that established the event. For example, if terminal A signals an event, terminal B cannot cancel the signal. Only terminal A can cancel it.

Examples

The following example shows how to cancel a DELAY statement.
mainproc: msgtxt
onin index(ru,'More...') > 0 then cancel delay
                                     /* Don't delay if screen needs */
                                     /* to be cleared.              */
type 'LISTFILE * * *'                /* List all files.             */
delay(40)                            /* Delay 40 seconds after      */
                                     /* next message is sent.       */
transmit
do while index(screen,'More...') > 0       /* Keep clearing screen  */
                                           /* as needed.            */
delay(40)                                  /* Reestablish 40-second */
                                           /* delay.                */
transmit using pa2                         /* Clear screen.         */
end
⋮
endtxt                                     /* End of Mainproc.      */

The following example shows how to cancel a SUSPEND statement.

sleep: msgtxt                  /* Go to sleep for one hour or until */
                               /* 'Hello' is received.              */
onin index(ru,'Hello') > 0 then cancel suspend
                               /* Wake up when 'Hello' is received. */
suspend(3600)                  /* Sleep for 1 hour (3600 seconds).  */
endtxt                         /* End of sleep.                     */

The following examples show how to cancel events.

signal 'SNOWFALL' after 5         /* Signal the event snowfall      */
                                  /* after 5 seconds have elapsed.  */
                                  /* The event tag defaults to the  */
                                  /* event name, SNOWFALL, since    */
                                  /* no event tag was specified.    */
⋮
cancel 'SNOWFALL'                 /* Cancels the event snowfall     */
                                  /* if 5 seconds have not elapsed. */

weather = 'ALL'                     /* Assign ALL to this variable. */
post 'RAIN' after 10 tag weather    /* Set up each of these events. */
reset 'SNOW' after 20               /* For the POST and SIGNAL      */
signal 'SLEET' after 30 tag weather /* events, assign an event tag  */
                                    /* equal to the value of the    */
                                    /* variable "weather".          */
⋮
cancel weather                    /* Cancels all events with the    */
                                  /* tag ALL provided the specified */
                                  /* time has not expired; the      */
                                  /* RESET event is not canceled    */
                                  /* because ALL does not match the */
                                  /* defaulted event tag SNOW for   */
                                  /* this event.                    */

Note

When coded as an asynchronous subset statement (CANCEL DELAY or CANCEL SUSPEND), this statement must be coded directly following the THEN keyword on the ONIN, ONOUT, or ON SIGNALED statement.