SED - Extension Programming
The extension programming feature allows users to add new functions to the editor. These may range from simple insertion or modification of text with a single keystroke to complex programs that manipulate the data to achieve tasks that are specific to your own editor usage.
Extensions may be stored in any QM file. Ideally, this should be a dynamic hashed file and SED uses &SED.EXTENSIONS& by default. A list of alternative locations to look for extensions can be defined using the $$EXTENSIONS variable described in SED Extensions - Variables, Constants and Functions. For all except the START.UP extension described below, if an extension is not found in any of these locations, a final check is made in the &SED.EXTENSIONS& file in the QMSYS account.
The editor looks for and executes an extension named START.UP on loading the first data record.
Extension names must be upper case and consist only of letters, digits, periods (.) and dollar signs.
Extensions must be compiled before use. This is performed using SED’s COMPILE command which recognises extension programs as distinct from QMBasic programs. The compiled version is stored in the same file as the source but with a suffix of -EXT added to the record name.
An extension is executed by the SED run extension function which is normally bound as Esc-E. Extensions may also be bound directly to user defined key sequences or made available via the command function. Typically this would be performed by the optional START.UP extension.
All those Brackets...
The extension programming language is based on the LISP language. This yields programs with very simple, though somewhat strange looking, structure.
Extension programs come in two types; procedures perform some operation whereas functions also return a value. The outermost structure of a procedure is
and for a function it is
where ...operations... is a sequence of steps that makes up the program.
A function returns a value using the return operation at any point in its execution. There is an implicit return of a zero value at the end of the function text.
Each of these operations is also a procedure or a function in that they perform some operation on the editing environment and/or they return information that can be used by other operations.
Each complete operation and any data items on which it works are enclosed in a further layer of brackets. Since the language allows functions to be nested to a high degree, a typical program at first appears to contain a large number of brackets. By applying some thought to the layout of the program, the actual structure can be made very clear to the reader. The language has no built-in format rules except that no token (individual word, constant, variable name, etc.) can span lines.
For example, a simple program to provide the equivalent of the STAMP command of ED could be written as:
(insert ‘*Last updated by ‘ @who ‘ (‘ @logname ‘)’
‘ at ‘ (oconv @time ‘MTS’)
‘ on ‘ (oconv @date ‘D4/’))
The screen is not updated during execution of an extension program except by functions that are documented as doing so. This allows the extension program to perform complex data movements without the screen continually tracking the internal workings of the extension. The screen is updated when the extension terminates.
For detailed information follow the links below: