[eclipse-clp-users] ECLiPSe stream usage

From: Giuseppe Di Guglielmo <giuseppe.diguglielmo_at_gmail.com>
Date: Fri, 13 Feb 2009 22:40:49 +0100
Dear all,
I attached a small test. In the code, I'm trying to retrieve the result for
the submitted constraint. Why does the 'ec_queue_read' function not collect
any data from the standard output (or error)?

In the 'clp_utils.ecl' file there are some other constraints (commented)
which I submit successfully in batch mode.

To compile and run it (cmake is needed):
$ unzip eclipse_stream.zip
$ cd work
$ cmake -C ../src
$ make
$ ./solve

---
#include "eclipseclass.h"

#include <iostream>
using namespace std;

main()
{
    char buf[1024];
    int n;

    ec_set_option_int(EC_OPTION_IO, MEMORY_IO);
    ec_init();
    
    ec_post_string("compile(clp_utils)");

    ec_post_string("integer_t(U, -128, 127), (U #= 11), search_int_func( U
)");
   
    // Try to uncomment this and comment previous: the following
'ec_queue_read' function retrieves Hello.  
    // ec_post_string("write(Hello)");

    ec_resume(); 

    while( (n = ec_queue_read(1, buf, 1024)) > 0 ) // DOES NOT WORK!
    {
      buf[n] = 0;
      cout << "eclipse: " << buf << "\n";
    }

#if 0
    n = ec_queue_read(2, buf, 1024);
    buf[n] = 0;
    cout << "eclipse error returned: " << buf << ".\n";
#endif

    ec_cleanup();
    exit(0);
}
---

Giuseppe





Received on Fri Feb 13 2009 - 23:10:35 CET

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