[top] [up] [next]

Microsoft Visual Basic Interface


It is possible to use the Trinc-Prolog DLL by programs developed with Microsoft Visual Basic. The basic file located at dll\vbasic\tp32.bas contains the Visual Basic declarations of the functions inside the DLL. In the subfolders of dll\vbasic there are examples developed with version 5 and 6 of Microsoft Visual Basic.
Do not forget to put the file tp32.dll and the files (system.txt, tcads.str, tcwin.str and pl.str) in a folder that is in the search path of Windows when running the application.

Function TPVersion () As Long
func Return the version number of the current interface of the DLL.
pre TRUE
post The version number was returned.

Function TPInit () As Long

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.

Function TPInit2 (ByVal Instance As Long) As Long

func Initialize the Trinc-Prolog DLL with the supplied instance handle.
pre TRUE
post If the DLL was correct initialized then was TP_TRUE returned, else a negative result  code was returned.

Function TPExit Lib () As Long

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

Function TPExit2 (ByVal Instance As Long) As Long

func Stop using the Trinc-Prolog DLL. The same Instance handle as used for initialization, is used to release the allocated resources. Any prolog engine instances still present 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.

Function TPNewEngine () As Long

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).

Sub TPDeleteEngine (ByVal EngineId As Long)

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

Function TPProve (ByVal EngineId As Long, ByVal Goal As String) As Long

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.

Function TPContinue (ByVal EngineId As Long) As Long

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.

Function TPNumVars (ByVal EngineId As Long) As Long

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

Function TPVarName(ByVal EngineId As Long, ByVal Index As Long) As String

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 an empty string was returned. To store the name of the variable create a copy of the returned character string.

Function TPVarValue(ByVal EngineId As Long, ByVal Index As Long) As String

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 an empty string was returned. To store the value of the variable create a copy of the returned character string.

Function TPVarType (ByVal EngineId As Long, ByVal Index As Long) As Long

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 was 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.

Function TPPutSettings (ByVal AppName As String, ByVal AppVersion As String, ByVal AppHelpFile As String, ByVal AppCopyright As String, ByVal AppCompanyName As String) As Long

func Set the name, version, help file name, 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 NIL.
post The supplied values were stored.
remark There is another version of this procedure that uses the pchar type instead of the string type for the parameters, this version of the function is called DLL_TPPutSettings.

[top] [up] [next]

 

info@trinc-prolog.com