Re: Calling Eclipse function from C++

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 16 Mar 2001 07:13:20 PM GMT
Message-ID: <3AB265D0.62B9CA69@icparc.ic.ac.uk>
Sathish Kumar Murugesan wrote:
> 
> But my problem is, how do I get the concat_test
> function compiled?

You post a compile-goal:

    post_goal("compile(mycode)");
    EC_resume();


> And what do I need to do if I want
> to return the value of X from the concat_test
> function?

You use an EC_ref where the ECLiPSe code expects a free variable:

    EC_ref X;
    post_goal(term(EC_functor("concat_test",3), "a", 123, X));
    EC_resume();

after the call, you can extract the result, e.g.

    char *s;
    if (EC_word(X).is_string(&s) == EC_succeed)
	cout << "Result is " << s << "\n";
    else
	cout << "No result\n";


-- 
 Joachim Schimpf              /             phone: +44 20 7594 8187
 IC-Parc, Imperial College   /            mailto:J.Schimpf@ic.ac.uk
 London SW7 2AZ, UK         /    http://www.icparc.ic.ac.uk/eclipse
Received on Fri Mar 16 19:14:08 2001

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:08 PM GMT GMT