[GAP Forum] Technical question / interface

Istvan Szollosi szteven at gmail.com
Fri Aug 31 00:08:38 BST 2007


Dear Thomas,

I'm working on a fully featured worksheet based graphical user
interface for GAP and have dealt already with this problem. If you
want the most possible control over the GAP process you should run it
with the -p option. When run as "gap -p", GAP will enter in a special
mode - suited for piping - and all GAP output is accompanied
(surrounded) by meta-characters (meta sequences begin with a '@'
character).

For example when you encounter in GAP's output "...blabla1234 at J@ngap>
@i" you'll know _for_sure_ that GAP has finished everything, displayed
the prompt and it's waiting for standard input. If an output line is
terminated by "@e" means GAP is waiting for "error output" etc.
This protocol is not that easy at first sight, but understandable if
you dive into the sources for the XGAP package. Also take a look at
how SAGE communicates with GAP:
http://www.sagemath.org/hg/sage-main?f=67e365631df5;file=sage/interfaces/gap.py
(search for the Python function "_execute_line").

If you absolutely need to do it in this way, i can also send you my
implementation with explanations, comments etc.

The interface will be out for testing in a few weeks (1-2) - (if
everything goes as planned :) ).

Regards,
      Istvan

PS: If you are concerned about efficiency and want to mix up GAP with
external code you have also the possibility to run an external process
from within GAP, or even compile GAP code into C with GAC (the GAP
compiler) and link it with yours - see the manual.

-- 
S. Szollosi Istvan
Babes-Bolyai University
Faculty of Mathematics and Computer Science
Faculty of Physics
Mihail Kogalniceanu nr. 1 RO- 400084 Cluj-Napoca, Romania
http://www.ubbcluj.ro



More information about the Forum mailing list