Translations of this page are also available in the following languages: Русский.

# Using REPL in gschem

## Embedded graphical REPL functions in gschem

The entry field for guile procedures is opened with hitting the key sequence `G``:` (g, colon). After doing this the user may enter commands in the appeared field and watch the results of their work in the gschem log window.

## REPL in the background terminal

There is an additional menu entry for working with REPL in the background terminal, which is invoked with hitting key sequence `G` `R`.

Please note, that for the moment you can run it several times, which may confuse your terminal. Moreover, there is a risk of closing working instance of gschem by using some shortkeys.

For more convenient work in the terminal you may want to turn on the functions of the readline library. For that, type in the terminal:

    (use-modules (ice-9 readline))
    (activate-readline)

## External graphical REPL

For invoking external graphical REPL window you have to have a REPL functions library from the guile-gnome. In Debian, for instance, you have to install the package guile-gnome2-gtk to may use it. To open the window, type in the field of the embedded REPL in gschem as follows:

    (use-modules (gnome-2) (gnome gtk) (gnome gtk graphical-repl))
    (guile-gtk-repl)

## REPL in any terminal

In order to invoke REPL in a terminal you have to open a REPL socket in gschem. To do so, load the system REPL module and call the function of server spawning:

    (use-modules (system repl server))
    (spawn-server)

When called without arguments, the spawn-server function uses the default guile port 37146. You can define another port:

    (spawn-server 1234)

When you're opening a port, please note the security risks described here.

Then you just need to connect to the port using any program which is able to do this, for example, telnet, netcat, or some other. Example of using telnet:

    $ telnet localhost 37146

Example of using netcat:

    $ nc localhost 37146

In this case the readline interface won't work.

Emacs users may use a shiny Geiser environment for working with REPL in that program. For that to work, you have to install this package, run the REPL server in gschem and connect to it in Emacs using `M`+`X` `connect-to-guile`.