HPlogo Asynchronous Serial Communications Programmer's Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 8 Intrinsics Reference

XCONTRAP

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

Arms or disarms the user written subsystem break trap handling procedure.

Syntax

I32V I32
XCONTRAP(plabel,oldplabel);

Use

The XCONTRAP intrinsic arms or disarms the user-written subsystem break ([CTRL]Y) trap handling procedure.

When a session is initiated, the user written [CTRL]Y trap handler is disarmed. If you are running a program in an interactive session, you can arm a special trap that transfers control in the program to a trap handling procedure whenever a subsystem break signal is entered from the session terminal. (This is called the [CTRL]Y trap since [CTRL]Y is the default subsystem break character.)

The subsystem break signal is normally transmitted by pressing [CTRL]Y. In transparent editing mode, you are allowed to define a different character to be used to invoke subsystem break by specifying the new character as part of param in a call to FCONTROL(41).

You can also use FDEVICECONTROL to alter the subsystem break character in either standard or transparent mode. See the discussion of the FDEVICECONTROL intrinsic earlier in this chapter for the proper parameter settings to use for this purpose.

If enabled, subsystem break allows the terminal user to stop a "program local" or "subsystem local" command. Before subsystem break can be enabled, however, you must call XCONTRAP, specifying the external label of a user written procedure which contains the steps that will be taken if subsystem break is entered during execution of your program as the value of plabel.

If it is desirable for your program to do so, subsystem break can be temporarily disabled through a call to FCONTROL(16). It can then be reenabled through a call to FCONTROL(17).

Only one process in a session can receive a [CTRL]Y trap at any one time. The process that called XCONTRAP most recently receives the next [CTRL]Y trap. Once a process has received a [CTRL]Y trap, it cannot receive another until it calls the RESETCONTROL intrinsic. Only processes running in a session (not in a job) can arm [CTRL]Y traps. The trap handler can be any procedure in the program or in the libraries to which the program is bound. The [CTRL]Y trap handler has no parameters.

The following summarizes subsystem break processing and the intrinsics involved:

  1. A user written procedure must be provided to define how the program should act upon receiving a subsystem break.

  2. A call to XCONTRAP must be included in the program, specifying the external label of the procedure written in Step 1 as the value of plabel. This arms the [CTRL]Y Trap.

  3. A call to FCONTROL(17) must be included in the program to enable the subsystem break function.

  4. If the subsystem break character is received during execution of the program, the procedure specified in the call to XCONTRAP is executed.

  5. A call to RESETCONTROL must be executed when the program is ready to receive another subsystem break.

  6. A new subsystem break character may be defined through FCONTROL(41), if the terminal is placed in transparent mode or through FDEVICECONTROL

  7. If desirable at any time, FCONTROL(16) may be called to disable subsystem break. A call to FCONTROL(17) enables it again.

Parameters

plabel

bit signed integer passed by value (required)

Passes the plabel of your [CTRL]Y trap handling procedure. This plabel can be either an NM or a CM plabel. If this value is 0, XCONTRAP disarms [CTRL]Y traps for the process.

How you obtain the external plabel of your NM trap handling procedure depends on your programming language. In Pascal/iX, for example, you can obtain the plabel by using the baddress or waddress function. Supply the name of your [CTRL]Y trap handler as an argument to baddress or waddress.

If a program executes only in native mode, it should have a native mode [CTRL]Y trap handler. Programs executing in compatibility mode must have a compatibility mode [CTRL]Y trap handler.

If a program executes in both compatibility mode and native mode, it is preferable to have an NM trap handler. However, it is possible to pass a CM plabel for your CM [CTRL]Y trap handler as follows:

Obtain the 16-bit external CM plabel of your CM [CTRL]Y trap handler.

Pass this 16-bit plabel in the following 32-bit format:

BitsSetting
(0:16)16-bit external CM plabel
(16:13)Reserved. Set to 0.
(29:1)Set to 1.
(30:1)Set to 0.
(31:1)Set to 1.

oldplabel

32-bit signed integer passed by reference (required)

Returns the plabel of the [CTRL]Y handler previously used by your process. This plabel can be either a CM or NM plabel, as described above. If no plabel was previously configured, oldplabel returns 0.

Condition Codes

CCE

Request granted. Trap enabled.

CCG

Request granted. Trap disabled.

CCL

Request denied because of an illegal plabel, or because XCONTRAP was called from a job.

Additional Discussion

See the discussion of enabling/disabling the user written [CTRL]Y trap handler in Trap Handling Programmer's Guide. See also the discussion of FCONTROL(16,17), FCONTROL(41), and RESETCONTROL in this manual. See Chapter 5 “Using Subsystem Break” of this manual for an example illustrating subsystem break processing.

Feedback to webmaster