From sli@sdlintl.com  Wed Nov 29 10:51:28 2000
Received: from targa_server.dccchina.com ([168.160.249.133])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id KAA12222
	for <prolog@swi.psy.uva.nl>; Wed, 29 Nov 2000 10:51:27 +0100 (MET)
Received: from stephen (somewhere.fmi.com [157.43.20.95]) by targa_server.dccchina.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2232.9)
	id W8NV9HTQ; Wed, 29 Nov 2000 17:40:17 +0800
Reply-To: <sli@sdlintl.com>
From: "Stephen" <sli@sdlintl.com>
To: <prolog@swi.psy.uva.nl>
Subject: help! about calling prolog from c++
Date: Wed, 29 Nov 2000 17:48:28 +0800
Message-ID: <NFEOJJODNDJNCCEBKNCKKEODCBAA.sli@sdlintl.com>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="gb2312"
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by swi.psy.uva.nl id KAA12222

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

