[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Exception Problem
From: |
Vasco Pires |
Subject: |
Exception Problem |
Date: |
Wed, 9 Jun 2004 16:14:54 +0100 |
Dear All,
I have a strange problem while calling Prolog from C.
In my project a call from C a Prolog predicate, that in some point
calls a C function to validate some data.
The problem is that the prolog predicate returns an exception to the C
code. The strange thing about this is that the C function that is
called from prolog returns False, and consequently fails the predicate.
If i comment this line and write Fail. The program works just fine and
doesn't return the exception.
Here is my C code that calls prolog:
int plGetBasicDecision( char** name, int *argument, double *xPos,
double *yPos, double *thetaPos )
{
int func;
WamWord arg[14];
Bool res;
int decision;
func = Find_Atom("makeAdvancedDecision");
Pl_Query_Begin(TRUE);
arg[0] = Mk_Variable();
arg[1] = Mk_Variable();
arg[2] = Mk_Variable();
arg[3] = Mk_Variable();
arg[4] = Mk_Variable();
arg[5] = Mk_Variable();
res = Pl_Query_Call( func, 6, arg );
if(res == 1) {
decision = Rd_Integer(arg[0]);
*name = Rd_String(arg[1]);
*argument = Rd_Integer(arg[2]);
*xPos = Rd_Float(arg[3]);
*yPos = Rd_Float(arg[4]);
*thetaPos = Rd_Float(arg[5]);
} else {
PlTerm except = Pl_Get_Exception();
printf("Exception of type: %d\n\n", Type_Of_Term(except));
decision = -1;
name = NULL;
}
Pl_Query_End(TRUE);
return decision;
}
Here is my prolog code that calls the C function:
fluentHasBall( Robot, s0 ) :-
plRobotHasBall( Robot ).
it returns an exception, and if I change to this:
fluentHasBall( Robot, s0 ) :-
fail.
it works just fine. the C function is:
Bool plRobotHasBall( char* Robot )
{
return FALSE;
}
Best Regards,
Vasco Pires
------------------------------------------------------------------
"Don't close your eyes unless you can dream. Don't open your eyes
unless you can believe!"
------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Exception Problem,
Vasco Pires <=