---
name: "megahal_interfaces"
section: "3"
platform: "linux"
package: "megahal"
version: "9.1.1a-9"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/megahal_interfaces"
---

# megahal\_interfaces(3)

C, Python and Tcl interfaces to Megahal

## NAME

megahal interfaces - C, Python and Tcl interfaces to Megahal

## SYNOPSIS

```
#include <megahal.h>

void megahal_setnoprompt(void);

void megahal_setnowrap(void);

void megahal_setnobanner(void);

void megahal_seterrorfile(char *filename);

void megahal_setstatusfile(char *filename);

void megahal_initialize(void);

char *megahal_initial_greeting(void);

int megahal_command(char *input);

char *megahal_do_reply(char *input, intlog);

void megahal_output(char *output);

char *megahal_input(char *prompt);

void megahal_cleanup(void);

```

## DESCRIPTION

**Initialization**\
 Megahal is initialized with the **megahal\_initialize()** function. **megahal\_setnoprompt** eliminates the prompt from interactive sessions.  **megahal\_setnowrap()** stops output from being wrapped. **megahal\_setnobanner()** prevents megahal from printing out the initial 'banner'.

**Files**\
 **megahal\_seterrorfile** and **megahal\_setstatusfile** set which files megahal will use for error and status reporting, respectively.

**User interaction**\
 **megahal\_initial\_greeting** returns an initial greeting for the user, such as "hello", "ciao", etc...  **megahal\_command** checks its input for a Megahal command (like QUIT), and acts upon it, if found.  If it finds nothing, it returns 0.  **megahal\_do\_reply** is the core of megahal.  It takes a string as input, and calculates a reply, which it returns.  **meghal\_output** is for outputting text to stdout, such as megahal's replies.  Input may be obtained with **megahal\_input**, which takes a prompt string as an argument, and returns a string input by the user.

**Example**\
 **main.c** in the source distribution is a good example of how to use Megahal's C API.

## TCL INTERFACE

**load** *libmh\_tcl.so*\
 Load the Tcl interface shared object into the Tcl interpreter.

**mh\_init**\
 Initialize megahal brain.

**mh\_doreply** *text*\
 Takes some text as input and returns a megahal reply.

**mh\_cleanup**\
 Save megahal brain to disk.  You will lose your changes if this does not occur.

## PYTHON INTERFACE

**import** *mh\_python*\
 Import the Megahal Python interface into the Python interpreter.

**mh\_python.initbrain()**\
 Initialize megahal brain.

**mh\_python.doreply(***text***)**\
 Takes some text as input and returns a megahal reply.

**mh\_python.learn(***text***)**\
 Takes some text as input and updates the model without generating a reply.

**mh\_python.cleanup()**\
 Save megahal brain to disk.  You will lose your changes if this does not occur.

## REFERENCES

More information can be found about megahal at http://megahal.sourceforge.net

Jason Hutchens, the original author of Megahal can be found at: http://www.amristar.com.au/~hutch/

## BUGS

The C library is not yet ready.

## AUTHOR

Man page written by David N. Welton \<davidw@dedasys.com\>, modified by Laurent Fousse \<laurent@komite.net\>.
