Writing a User Procedure

Procedures to be called by the Proc command must be written in SPL or FORTRAN and have the following header structure:

  logical procedure name       (linebuffer,        linelength,        linenumber,        procspace);  byte array linebuffer, <<type char in ftn>>        linenumber;  array procspace;  integer linelength;  option external;  

The parameters are defined as follows:

LINEBUFFER: A character array containing the data of a line, left-justified. If the line is to be modified, the procedure must return the new line data in this buffer. There is room in LINEBUFFER for an extra stop character if you need it.

LINELENGTH: An integer simple variable containing the length of the line in bytes. If the procedure changes the length of the line, it must update this variable. If the new length is greater than the size allowed, Qedit truncates the length. If the value returned is less than 0 and the procedure returns a “true” result, but not 111, Qedit deletes the line.

LINENUMBER: A byte array containing the line number in 10 ASCII characters, display format. This field must not be changed by the procedure. If invoked to modify a command line, LINENUMBER is set to “COMMAND”.

PROCSPACE: A global array of 28 words that remains the same between calls to procedures. The first 20 words of PROCSPACE are reserved for user code and are initialized to binary zero; they can be reset to zero by using PQ (example: PQ M,S,510). Individual words in the workspace can be changed with the Proc command itself (see below). For the meaning of the other 8 words of PROCSPACE and for access to the 10-word USERSPACE array, see User Interface Procedures.

The procedure must return a “true” (-1) or “false” (0) result in its name, since it is a function. If the procedure returns “false”, the Proc command stops, even though the rangelist may not be done, and the line is not updated. Only the first LINELENGTH bytes of LINEBUFFER are guaranteed to have meaningful characters in them, although the buffer is actually 257 bytes long. If the result is 111 (true), Qedit continues processing the rangelist, but does not update the current line; this can save considerable overhead in scanning procedures.

See FINDJUNK and NEATER in Routines.Qlibsrc.Robelle.

Writing a User Procedure