[top] [up] [next]

Borland C++ Builder interface


For C++ Builder a component class can be used or the functions of the C interface. Using the component class makes the program simpler because instances of the component class automatically take care of initialization, exiting the DLL and storing the engine id. The component class is called TPrologEngine and it is located in the file dll\cbuilder\comp\tcomp.h. The declaration of the component class is:

TPrologEngine
    TPrologEngine( TComponent* Owner )   
func Constructor.
pre TRUE
post The DLL will be loaded if the first instance of the class is created.
virtual ~TPrologEngine( void )
func Virtual destructor.
pre TRUE
post The instance was deleted, if the last instance is deleted the DLL will be unloaded.
static int Version( void )
func Return the version of the Trinc-Prolog DLL interface.
pre TRUE
post A version number was returned.
int Prove( char *Goal )
func Prove the goal.
pre A goal to prove must have been supplied.
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 Continue( void )
func Find the next solution.
pre A solution must have been found by a previous call to the method 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 NumVars( void )
func Return the number of variables in the last solution.
pre A solution was found.
post The number of variables was returned.
const char *VarName( int Index )
func Return the name of a specific variable from the last solution.
pre A solution was found AND "Index" >= 0 AND "Index" < "NumVars".
post The name of the variable was returned.
const char *VarValue( int Index )
func Return the value of a specific variable from the last solution.
pre A solution was found AND "Index" >= 0 AND "Index" < "NumVars".
post A string representation of the value was returned.
int VarType( int Index )
func Return the type of the value of a specific variable from the last solution.
pre A solution was found AND "Index" >= 0 AND "Index" < "NumVars".
post One of the following values will be returned:
    TPTYPE_UNKNOWN
    TPTYPE_EMPTYLIST
    TPTYPE_LIST
    TPTYPE_EMPTY
    TPTYPE_INTEGER
    TPTYPE_FLOAT
    TPTYPE_STRUCTURE
    TPTYPE_ATOM

In C++ Builder the component class cannot be added to the component palette because no additional library can be specified during the compilation of the component library (cmplib32.ccl), without the library file tp_32.lib the linker reports 'undefined symbol ... errors'.

C++ Builder version 3

When compiling the examples with C++ Builder 3 make sure that the SolutionsForm in the example is not made an autocreate form and that the main file tp_test.cpp is not included in the project if C++ Builder 3 has already generated a main file with a message loop.

[top] [up] [next]

 

info@trinc-prolog.com