TEACH POPCOURSE13 - The rest of Poplog

Contents

The core features of Poplog are the compilers for the various supported languages and the Ved editor. The previous file examined the program interface to the Ved editor. The present file will examine some of the more useful, non-core features of Poplog. Its aim is to present a brief overview of some of the extras and `goodies' that the environment provides.


Multi-language programming

Poplog presently provides compilers for POP-11, Common Lisp, Prolog and Standard ML. In addition to the support it provides to the programmer working with one of these languages, it also provides support for people wishing to make use of more than one language in one program. In some situations this is very convenient. For example, one might want to use Prolog for its built-in search ability but without loosing the flexibility and power of the POP-11 matcher. In Poplog it is possible to draw functionality from many different languages. For example we can quite easily combine POP-11 code and Prolog code in the same program.

An entry point for the documentation on multi-language programming is HELP SUBSYSTEM. Basic information on calling Prolog from POP-11 is given in HELP POPTOPLOG.


X-windows interface

Poplog was originally implemented for use with VDU-style terminals with no graphics capability. Since then graphics workstations have become much more widely available. As a result Poplog now provides support for graphical interactions. This support comes mainly in the form of a comprehensive interface to the X-windows system (see HELP X). This is the windowing environment that many workstations use. There are various library packages that can be loaded under Poplog via the Ved command `ved_lib' or the POP-11 command `lib' (see HELP LIB). For example the following code loads a convenient user interface to the X-windows procedures, opens a graphics window and draws some objects in it. Note that this code will only have the desired effect if you are using a terminal running X-windows.

lib rc_graphic;
rc_start();
rc_draw_oblong(50,80,20);
rc_draw_oblong(200,50,10);

Display packages

Poplog provides a variety of packages that enable the user to create and manipulate displays. One of the most basic of these packages is provided by the library called `showtree'. This can be made available by giving the command `lib showtree'. Once this has been done, the `showtree' procedure can be used to display in a Ved file the `tree' structure of a list. For example, the code

lib showtree;
showtree([root [foo [bang [ding dong] bing] [bang bong]]]);
constructs a file with the argument list displayed in the form of an upside-down tree. Note that you may have to press the SWAPFILES key to see the file.

The `showdisplay' package (local to Sussex) contains a set of display procedures all of which are capable of producing displays in a number of different formats. By default they produce a graphical display using the X-windows system. If there is no X-windows system running, they produce the display as a Ved file. By giving arguments to the relevant commands it is also possible to make the procedures produce displays in `fig', `troff' and `latex' format. You can get a feeling for what this package does by executing the following example. See HELP SHOWDISPLAY.

lib showdisplay;

showdisplay([
   {line 2 28 20 28 [1]}
   {line 2 29 20 29 [2]}
   {line 2 30 20 30 [3]}
   {line 2 31 20 31 [4]}
   {circle 3 3 7 7 'turquoise' 1.0}
   {circle 20 6 24 10 'yellow' 1.0}
   {box 5 5 25 25 'magenta' 0.0}
   {box 20 20 22 22 'orange' 1.0}
   {string 29 4 'these are weights' 6 'brown'}
   {weight 27 16 29 18 0.9}
   {weight 27 18 29 20 -0.4}
   {line 8 6  20 15 24 'lime green'}
   {arrow 36 5 30 15}
   {string 10 19 'there' 'red' 24}
   {string 10 16 'hello' 'blue' 12}
   ]);

The external interface

The languages that Poplog supports directly are high-level programming languages. These are languages that provide a maximum convenience without worrying too much about efficiency and speed. For some purposes, efficiency is essential. In these cases, the Poplog user can construct programs using a lower-level language (e.g. C) and link it in to a POP-11 program. Having done this, procedures in the lower-level program can be called simply by calling the relevant POP-11 procedures.

The following example (taken from HELP EXTERNAL) demonstrates the linking in of a small C procedure. To run the example copy the C code below into a file called `array.c' and compile it with the operating system command `cc -c array.c'. An object file called `array.o' will be created.

/* print the contents of a two dimensional integer array */

void prarr(array, xsize, ysize)
int array[], xsize, ysize;
{
    int i;

    for (i = 0; i < xsize * ysize; i++)
    {
        printf("%d ", array[i]);
        if ((i + 1) % xsize == 0)
            printf("\n");
    }
}
Then load the following

lib external;

external declare array in c;
    void prarr(array, xsize, ysize)
    int array[], xsize, ysize;
    {}
endexternal;

external load array;
    array
endexternal;
We now have a POP-11 procedure that calls the C procedure `prarr'.

prarr ==>

** <procedure prarr>
To use it we need to set up an array of numbers.

vars a = array_of_int([1 10 1 10],  procedure (i, j);
                                        random(9);
                                    endprocedure);
We can then execute it as follows.

prarr(a, 10,10);

Object-oriented programming

Within Poplog POP-11 there are various packages that implement `object-oriented programming' systems. These include the package described in HELP FLAVOURS and the package described in HELP NEWOBJ. In addition to these there may be other, possibly local packages that support this programming style. See HELP LOCALNEWS.


Menus

There is a suite of local facilities that implement menu-based operations of various kinds. These are all based on the `menuselect' procedure (automatically available if you are at Sussex). In the simplest case, the `menuselect' procedure takes a list as argument. It then displays the list as a menu in a Ved file. The user is able to move the cursor around as usual. Each press of the space-bar over an item effectively selects that item. The first press of RETURN terminates the interaction and returns any selected items as a list. Try the following.

menuselect([chips beans steak carrots]) ==>
The `menuselect' procedure is highly customisable; see the relevant HELP file. For information on the commands that make use of `menuselect' see HELP POPMENUS.


Mail processors

Electronic mail is increasingly treated as the primary mode of communication in academic environments (and elsewhere). Many mail-processing programs exist in addition to the basic `mail' utility that is available under UNIX. Some of these are implemented as Poplog software packages. The main advantage of using one of these packages is that you can process your mail using the ordinary, Poplog user interface (i.e., the Ved editor). This saves you the trouble of learning a new interface. You may also find it convenient to be able to transfer material into and out of mail messages using the standard Ved commands.

A basic Poplog mail processing facility is provided by the Ved `mail' command. Usage of this command is provided in HELP MAIL. A more advanced and widely-used package is provided by the `vmail' command. See HELP VMAIL. Finally there is `cmail', see HELP CMAIL. This shares certain features with `vmail' but, in addition, allows you to process `news' messages in exactly the same way as mail messagse. It also povides automatic logging of messages.


Bibliography services

A common task in academic settings is that of creating a list of references. This task can be made much easier by software that is able to read in source files and automatically append lists of references to the end of the text. The Poplog local library package called `bibtool' implements this facility. It is fully described in HELP BIBTOOL.


Other packages and features

The facilities listed above provide just a flavour of the sorts of things that are available. Other files you might like to investigate include

To get the full picture you will have to explore your way around the documentation system, checking out cross-references etc. You will also find it helpful to read the various NEWS files, see HELP NEWS and HELP LOCALNEWS. This give news of new additions to the system. By reading old versions of HELP NEWS you can get clues as to what other goodies are available.


Exercises

There are no exercises for this file.


Moving on

This file is the last in the `POPCOURSE' series.


Page created on: Fri Apr 26 09:35:07 BST 2002
Feedback to Chris Thornton
hits this year