Re: [eclipse-users] more questions although there are no replies :(

From: J. Manuel Velasco <jvelasco_at_guest.uji.es>
Date: Mon, 6 Nov 2006 13:41:20 +0100
Dear Joachim,

Thanks to you I am advancing in this task.

What I really need to execute in prolog from C++ are CHRs.

I've create an unique file to compile from C++ two files:

%-----------------------------
% prologCode.pl
:- [orientacion_main,orientacion_chr].
main(A,B,C,D) :- ctr_orient(C,A,B,[lm]),ctr_orient(D,C,B,[lm]).
%-----------------------------

"orientacion_chr" is the result to execute chr2pl.

The C++ file is the following:

% orientacion.cc
main()
{

ec_init();

post_goal(term(EC_functor("compile",1),"prologCode"));

if (EC_resume() != EC_succeed)
{
  cout << "Compilation failed\n";
  exit(-1);
}

EC_ref Result;
EC_ref A,B,C,D;
string prologOutput;

// Try  to call the prolog main function defined in prologCode
post_goal(term(EC_functor("main",4), A,B,C,D, Result));
if (EC_resume() == EC_succeed)
{
   // Asingnation error
   // prologOutput = Result;
   cout << prologOutput;
   post_goal(EC_atom("fail"));  
  }
else
 {
   cout << "goal failed" << endl;
 }

// There is no operator<< defined to EC_ref type.
//cout << prologOutput << endl;
ec_cleanup();    

}


If I make this process in eclipse it works fine:

[eclipse 1]: [prologCode].
orientacion_main.pl compiled traceable 50264 bytes in 0.00 seconds
chr2pl.eco loaded traceable 0 bytes in 0.01 seconds
chr.eco    loaded traceable 0 bytes in 0.02 seconds
orientacion_chr.pl compiled traceable 153508 bytes in 0.05 seconds
prologCode.pl compiled traceable 200 bytes in 0.05 seconds

Yes (0.05s cpu)
[eclipse 2]: main(A,B,C,D).
lists.eco  loaded traceable 0 bytes in 0.00 seconds

A = A
B = B
C = C
D = D


Constraints:
(2) ctr_orient(1, C_255, A_269, B_283, [lm], 1)
(4) ctr_orient(1, D_1187, C_255, B_283, [lm], 1)
(5) ctr_orient(3, D_1187, A_269, B_283, [lf, l, lm], 2)
(9) ctr_orient(5, D_1187, C_255, A_269, [lm, ibl, bl, sb, br], 2)
Yes (0.01s cpu)

But from C++ I don't know how to get the result of the CHR execution.

I am still trying to find the way. Any help/guide will be really appreciate 
again.

Thanks a lot.

Your sincerely,
 ·_- manou
Received on Mon Nov 06 2006 - 12:40:54 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:57 CET