Hi,
i am trying to get a delphi port of the swi header files and some supporting units in delphi done, the basic idee is to use prolog (and CHR) for business rules.
Up to now, everything runs fine, i can import the dll, i can define and call predicates, either build-in predicates like ‘consult’ or self defined ones.
But i got a problem with the use of pl_open_query / pl_next_solution on predicates with more then one solution.
Opening the query with pl_open_query runs fine, calls to pl_next_solution or pl_close_query will always fail. If i call the same predicate under the same circumstances with pl_call_predicate it works.
The following is just a example for testing, the predicate “weiblich” is defined in the consulted file.
It makes no difference if i call pl_open_foreign_frame() before, it makes no difference if i construct the predicate using pl_pred/pl_new_functor, it makes no difference if i change the definition of qid_t, it makes no difference if i change the definition of pl_open_query or pl_next_solution. I guess i have tested every possible combination, so i have no further idees.
I always got an runtime error during a call to PL_next_solution(query) and/or PL_close_query(query).
/// p is just a wrapper component.
p.Initialize();
if p.ConsultFile(edConsultFile.Text) then
begin
//frame := PL_open_foreign_frame();
pred := PL_predicate('weiblich', 1, nil);
//pred := PL_pred(PL_new_functor(PL_new_atom('weiblich'), 0), nil);
t := PL_new_term_refs(1);
pl_put_variable(t);
query := pl_open_query(NIL, PL_Q_NORMAL, pred,t);
while CHCK(PL_next_solution(query)) do
begin
end;
pl_close_query(query);
end;