[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Tue, 12 Oct 2004 08:38:48 +0000 (UTC) 
Subject:External programs / Stand alone programs in pop11/poplog 
From:A . Sloman 
Volume-ID: 

Wayn wrote:

> 3. how to i run external programs such as ( cdplayer
> or notepad, text editor etc... from within a poplog
> program   and how can a poplog program be compiled and
> run as a stand alone application

Those are two different questions:

> 3. how to i run external programs such as ( cdplayer
> or notepad, text editor etc... from within a poplog
> program

The easiest way is to use sysobey. If you are using windows
poplog I have no idea whether that would work or not.

On unix/linux poplog systems

    sysobey('who');

runs the 'who' command showing who is logged in.

It is not advisable from Ved, as the output to the terminal and
Ved's view of the terminal will not necessarily be compatible.

If you ran XVed from the command line in an xterm window, then
the output of who will come out in the xterm window.

Alternatively you can do this in Ved

    veddo('sh who');
or
    ENTER sh who

and the output of the who command will come in another ved
buffer, which can be very useful, e.g. with programs like
'ls'.

If you wish to start up another program and not wait for it to
finish, use '&' to run the program in the 'background'.

E.g. in linux/unix this will launch a new xterm window:

    sysobey('xterm &')

If you wish to run a program that interacts with your pop11
process things get much more complex. See these help files

    HELP pipeutils
    HELP pipein
    HELP pipeout
    HELP run_unix_program

You can also invoke programs written in C or Fortran via the
external procedure interface documented in

    HELP external
    HELP newc_dec
    REF external
    REF defstruct
    REF external_data

David Young's popvision library uses those mechanisms to invoke
image processing procedures written in C from pop11.

I have never directly used most of that stuff myself, but the
whole of the poplog X window interface (including XVed) depends
on it. See all the documentation in

    $usepop/pop/x/pop/teach/*
    $usepop/pop/x/pop/help/*
    $usepop/pop/x/pop/ref/*

> and how can a poplog program be compiled and
> run as a stand alone application

That's a long and complicated story, which as far as I know
is not well documented for novices. See
    HELP popc
    REF popc

If anyone who has used these mechanisms would like to donate a tutorial
example to the poplog web site, I am sure that would be much
appreciated.

If I wanted to do it I would do it a different way.

I would try to implement my application as a saved image, just
as much of pop11 (including XVed) is provided as a saved image
in startup.psv which runs on top of basepop11, and prolog
is a saved image prolog.psv, which runs on top of startup.psv
and basepop11. The best way to learn how to make a saved image
is to copy the mechanisms used to create the system
saved images, e.g.

    $popcom/mkstartup
    $popcom/mkclisp
    $popcom/mkprolog
    $popcom/mkeliza

The cost of using the saved image mechanism for a stand-alone
application is that you include a lot of the standard poplog
run time system and there's an overhead in starting up a
core executable + saved image.

However with memory cheap and getting steadily cheaper, and
processors thousands of times faster now than they were a few
years ago and getting steadily faster, I can't see any point
wasting human time to get minor efficiency gains, if your
application is complex enough to benefit from a rich run-time
system like poplog.

If it is not complex enough, then maybe programming in a simpler
language like C or C++ or some other would suffice?

Another approach, which would be more hassle, but could produce a
more compact and efficient stand alone application would use the
mechanisms for rebuilding poplog, as described here
    http://www.cs.bham.ac.uk/research/poplog/sysdoc/

I would copy the poplog system, remove things not needed for the
application, e.g. Ved and all the X stuff, perhaps and then add
new things to the system sources (after making sure they run OK
in ordinary pop11). Adding programs to the system sources
requires understanding the conventions used in the sources, and
may require some changes to the code. Then recompile, archive and
relink the reduced system + application code.

That's *far* more hassle than using a saved image, and you lose
the benefit of being able to redefine procedures during
interactive testing, but the end result will be more compact
and perhaps more efficient. But hardware developments in the
next few years will produce much greater speed benefits. The
cost of a new PC in two years time will be far less than the
cost of a few weeks of a programmer's time.

Aaron
==
http://www.cs.bham.ac.uk/~axs/