Subject: help! about calling prolog from c++

From: "Stephen" <[email-masked]>
Date: Wed, 29 Nov 2000 17:48:28 +0800

Hi, everybody!
I meet a problem about calling prolog from c++ program, who would help me?
I wrote a c++ function  as following code to call prolog, but the return value( char* ptext) is null after running SP_next_solution(goal).
While i run this prolog predicate "pos" , the second parameter return a right value, such as: [[ for example]], anything wrong?
What can i do for it?

void fuc(CString strWord)	
{	
	SP_pred_ref pred;
	SP_qid goal;
	SP_term_ref src, res;

	if (!(pred = SP_predicate("pos",2,"")))
	{
		AfxMessageBox("Could not find pos/2!");
		return;
	}

	SP_put_string(src = SP_new_term_ref(), (char*)(LPCTSTR)strWord);
	SP_put_variable(res = SP_new_term_ref());

	if (!(goal = SP_open_query(pred,src,res)))
	{
		AfxMessageBox("Failed to open query!");
		return;
	}

	char ptext = null;
	while (SP_next_solution(goal))
	{
		SP_get_string(res, &ptext);
	}
	
	.....
}

Stephen Li