[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Tue, 6 Apr 2004 21:44:53 +0000 (UTC) 
Subject:Re: Communicating with RCLIB 
From:A . Sloman 
Volume-ID: 

John Duncan wrote:

>    Is it possible to fork an instance of a Pop11 program
> as a child process of a C program ?

That's essentially what the unix shell does when you run pop11
so I don't see why a C program should not do it.

It's also what the Emacs package for poplog users does. You
probably have it as emacs.tar.gz even if you have never used it.

I don't know if the code in there is transparent enough to give you
ideas. I've never used it though others have.

>    The idea is to fork an instance of a rclib control panel
> as a child process of the C program and talk to rclib via
> two pipes. You send Pop11 commands down the pipe to rclib,
> which executes them ( by drawing the graphics etc.). You
> also have rclib print strings to its standard ouput in
> response to events ( like clicking on a button in the rclib
> control panel) - the C program can recieve these strings
> from the read pipe and act upon them.

I suspect the easiest thing to start with would be to create an
executable shell script that runs pop11 in such a way that it enters a
loop that merely reads from the input and sends something to the output,

e.g. create a script called echo containing

    #!/bin/bash

    pop11 ":repeat lvars line = readline(); line <> line => endrepeat;"

This format, where the argument starts with a colon. Makes pop11
treat the rest of the argument as if it were a command typed in.

When that runs, it uses readline() to read a line of text from the
current input, then makes a list of words out of it, then concatenates
the list to itself and prints it out.

Besides readline there are many other options:
    REF CHARIO
    HELP READITEM


That script can be run from the shell ok. You have to exit by
interrupting, e.g. ctrl C.

I assume it can also be run from a C program that generates and pipes
out newline-terminated strings and reads in newline-terminated strings.

If you can make something like that work, then instead of the simple
loop you can make the pop11 command compile a file, that defines
various procedures then runs something including rclib, Xved,
or anything else.

The format is

    pop11 filename.p

(The file can be in one of the directories in $popcomppath )

It can end with a loop reading text from the standard input and
processing it, or the call of a procedure that does that.

If the program runs rclib, then the graphical devices produced by rclib
should react to mouse and keyboard actions. But have not tried it.

>    I am also looking at Propsheets and Motif for this but
> don't claim to be sure of what I am about. It is mainly a
> learning exercise.

The golden rule is

    *start simple*

First make something work without fancy graphical tools.
Then gradually extend it.

I hope that helps.

Aaron