After the successful return of
PrologNextSolution, the values
assigned to the variables of the query can be retrieved by specific
functions of the interface. There are separate functions for retrieving
the variable values in string, quoted string and integer formats.
PrologGetLong function retrieves the integer value of a given
variable within a query and assigns it to a variable. That is, the
value of the given variable is converted to an integer. Returns 1 on
The following code fragment assigns the value 2 to the variable
Dim qid As Long Q = "member(X,[1,2,3]), X > 1" qid = PrologOpenQuery(Q) Call PrologNextSolution(qid) Call PrologGetLong(qid,"X",v)
PrologGetString function retrieves the value of a given
variable in a query as a string. That is, the value of the variable is
written out using the
write/2 Prolog predicate, and the resulting
output is stored in a Visual Basic variable. Retuns 1 on success.
Example: suppose we have the following clause in a Prolog program:
The code fragment below assigns the string
"Sweden-Stockholm" to the variable
Dim qid As Long Q = "capital_of(Expr)" qid = PrologOpenQuery(Q) If PrologNextSolution(qid) = 1 Then Call PrologGetString(qid,"Expr",capital) End if Call PrologCloseQuery(qid)
PrologGetStringQuoted function is the same as
PrologGetString, but the conversion uses the
Prolog predicate. Returns 1 on success.
if the function
PrologGetStringQuoted is used in the code above
instead of the
PrologGetString function, then the value assigned to
The only way of transferring information from Prolog to Visual Basic is
by the above three
PrologGet... functions. This means that,
although arbitrary terms can be passed to Visual Basic, there is no
support for the transfer of composite data such as lists or
structures. We will show examples of how to overcome this limitation
later in the manual (see vb-ex).