TRAPCLR


ANSI

 

The TRAPCLR instruction is clears a previously set trap. It uses one of the following formats:

 

(1)

[label]

TRAPCLR

{event}

(2)

[label]

TRAPCLR

ALL

(3)

[label]

TRAPCLR

ALLCHARS

(4)

[label]

TRAPCLR

ALLFKEYS

(5)

[label]

TRAPCLR

ALLKEYS

 

Where:

label

Optional. A Program Execution Label.

event

Required. One of the trappable program Events.

Flags Affected: NONE

Note the following:

  1. ALL specifies that all events that are trapped are cleared.

  2. CHARS specifies that all {char} events that are trapped are cleared. Unless the program was compiled with the ANSI switch, only one {char} event may be trapped at a time. Otherwise, any keyboard character may be trapped.

  3. ALLFKEYS specifies that all function key events that are trapped are cleared.

  4. ALLKEYS specifies that all {char} events and all function key events that are trapped are cleared.

  5. It is not necessary to execute a TRAPCLR on an event prior to setting another TRAP for the same event.

 

Example 1:

 

  

TRAP

NOMASTER IF IO

  

OPEN

APMASTER,"ACCTSPAY"

  

TRAPCLR

IO

 

The TRAP instruction specifies that the program should CALL the subroutine NOMASTER if an IO error occurs. After the logical file APMASTER is opened, it is recommended that the IO trap be cleared or set to another routine. The TRAPCLR IO clears the previously set TRAP for IO.

 

Example 2:

 

(1)

  

TRAP

NOMASTER IF IO

  

OPEN

APMASTER,"ACCTSPAY"

  

TRAPCLR

IO

  

TRAP

BADIO IF IO

 

(2)

  

TRAP

NOMASTER IF IO

  

OPEN

APMASTER,"ACCTSPAY"

  

TRAP

BADIO IF IO

 

Since only one TRAP may be set for each possible event, the second TRAP replaces the previous TRAP until an appropriate TRAPCLR is executed, the trapped for event occurs or the program terminates.

 

Example 3:

 

  

TRAPSAVE

SAVETRAP

  

TRAPCLR

ALLKEYS

  

TRAP

HELP IF F1

  

TRAP

WRITE IF F3

  

...

 

  

TRAPREST

SAVETRAP

 

This section of code saves the currently set traps, clears all function key traps, sets new traps for F1 & F3. At the end of the routine, the original traps are reset using the TRAPRESTORE instruction.

 

 

See Also: CALL, Trap Events, Exceptions, Program Control Instructions

 



PL/B Language Reference TRAP TRAPRESTORE