Passing Control and Data to ECLiPSe from C++

## B.7 Passing Control and Data to ECLiPSe from C++

These are the functions needed to embed ECLiPSe into C++ code.

void post_goal(const EC_word)
void post_goal(const char *)
  post a goal (constraint) that will be executed when ECLiPSe is resumed.
int EC_resume(EC_word FromC, EC_ref& ToC)
int EC_resume(EC_word FromC)
int EC_resume()
  resume execution of the ECLiPSe engine: All posted goals will be executed. The return value will be EC_succeed if the goals succeed (in this case the ToC argument returns a cut value that can be used to discard alternative solutions). EC_fail is returned if the goals fail, and EC_yield if control was yielded because of a yield/2 predicate call in the ECLiPSe code (in this case, ToC contains the data passed by the first argument of yield/2). If a writable queue stream with yield-option (see open/4) was flushed, the return value is PFLUSHIO and ToC contains the associated stream number. If there was an attempt to read from an empty queue stream with yield-option, the return value is PWAITIO and ToC contains the associated stream number. Moreover, if the previous EC_resume yielded due to a yield/2 predicate call, The term FromC is passed as input into the second argument of yield/2 on resuming.
void EC_ref::cut_to()
  Should be applied to the ToC cut return value of an EC_resume(). Cut all choicepoints created by the batch of goals whose execution succeeded.
int post_event(EC_word Name)
  Post an event to the ECLiPSe engine. This will lead to the execution of the corresponding event handler once the ECLiPSe execution is resumed. See also event/1 and the User Manual chapter on event handling for more information. Name should be an ECLiPSe atom.