[top] [up] [next]

C interface


For compiling an application with the C interface the import library tp_32.lib can be used for linking. The library was buildt with Borland C++ Builder 5. The header file to use is called tp_dll.h and is located in the folder dll\c. In that same folder there is also an example of using the C interface. The C interface consists of the following functions:

int DLL_TPVersion( void )
func Return the version number of the current interface of the DLL.
pre TRUE
post The version number was returned.

int DLL_TPInit( void )

func Initialize the Trinc-Prolog DLL. The instance handle of the DLL is used to initialize it.
pre TRUE
post If the DLL was correct initialized then was TP_TRUE returned, else a negative result  code was returned.

void DLL_TPExit( void )

func Stop using the Trinc-Prolog DLL. Any still present Prolog engine instances are deleted.
pre TRUE
post The DLL can no longer be used, all the allocated resources of the DLL were released.

void DLL_TPExit( HINSTANCE Instance )

func Stop using the Trinc-Prolog DLL. The same Instance handle as used for initialization is used to release allocated resources. Any still present prolog engine instances are deleted.
pre The same instance handle must have been used for initialization.
post The DLL can no longer be used, all the allocated resources of the DLL were released.

int DLL_TPNewEngine( void )

func Create a new Prolog engine instance and initialize it.
pre The DLL must have been successfully initialized.
post The engine identifier of the new Prolog engine instance was returned, if there was an error then a negative error code was returned (< 0).

void DLL_TPDeleteEngine( int EngineId )

func Delete the engine specified by the identifier "EngineId".
pre TRUE
post The engine with the same identification number was deleted.

int DLL_TPProve( int EngineId, char *Goal )

func Have the specified goal proven by the engine identified by "EngineId".
pre The parameter "Goal" may not be NULL.
post If the goal was proven successfully and a solution was found was TP_SOLUTION returned, if the goal failed then was TP_FAIL returned, else one of the following error codes: "TPERROR_INCORRECT_GOAL", "TPERROR_UNKNOWN_ENGINE" or "TPERROR_PROVE" was returned.

int DLL_TPContinue( int EngineId )

func Continue proving the current goal of the engine until the next solution.
pre A solution must have been found by a previous call to the function Prove.
post If the goal was proven successfully and a solution was found was TP_SOLUTION returned, if the goal failed then was TP_NO returned, else one of the following error codes: "TPERROR_INCORRECT_GOAL", "TPERROR_UNKNOWN_ENGINE" or "TPERROR_PROVE" was returned.

int DLL_TPNumVars( int EngineId )

func Retrieve the number of variables in the last solution found by the specified engine.
pre A solution was found.
post The number of variables was returned, if the engine was not found then TPERROR_UNKNOWN_ENGINE is returned, else the number of variables was  returned.

const char *DLL_TPVarName( int EngineId, int Index )

func Get the name of the specified variable of the last solution generated by the engine identified by "EngineId".
pre A solution was found AND "Index" >= 0 AND "Index" < "NumVars".
post If the variable was found then the name of it was returned, else was NULL returned. To store the name of the variable create a copy of the returned character string.

const char *DLL_TPVarValue( int EngineId, int Index )

func Get the value of the specified variable of the last solution generated by the engine identified by "EngineId".
pre A solution was found AND "Index" >= 0 AND "Index" < "NumVars".
post If the variable was found then the value was returned, else was NULL returned. To store the value of the variable create a copy of the returned character string.

int DLL_TPVarType( int EngineId, int Index )

func Get the type of the value of the specified variable of the last solution generated by the engine identified by "EngineId".
pre A solution was found AND "Index" >= 0 AND "Index" < "NumVars".
post If the variable was found then the type of the value was returned, else is TPTYPE_UNKNOWN returned. The following type constants are defined:
    TPTYPE_UNKNOWN = No value or unknown type.
    TPTYPE_EMPTYLIST = An empty list.
    TPTYPE_LIST = A list with elements.
    TPTYPE_EMPTY = An empty variable.
    TPTYPE_INTEGER = An integer number value.
    TPTYPE_FLOAT = A floating point value.
    TPTYPE_STRUCTURE = A structure value.
    TPTYPE_ATOM = An atom value.

void DLL_TPPutSettings( const char *AppName, const char *AppVersion, const char *AppHelpFile, const char *AppCopyright, const char *AppCompanyName )

func Set the name, version, help file, copyright message and company name of the application. These values are displayed if the user for instance opens the About dialog from inside A TPWin application being interpreted by the Trinc-Prolog DLL.
pre Any of the parameters may be NULL.
post The supplied values were stored.

[top] [up] [next]

 

info@trinc-prolog.com