How to convert DataObject type to other data type?

61 views
Skip to first unread message

antangzhu

unread,
May 23, 2012, 9:51:44 PM5/23/12
to CLIPSESG
Hello,
i have following codes:

#include "clipscpp.h"
#include <iostream>
using namespace CLIPS;
using namespace std;
int main()
{
CLIPSCPPEnv theEnv;
DataObject theData1;
theEnv.Load("test01.clp");
theEnv.Reset();
theEnv.Run(-1);
theData1 = theEnv.Eval("(fact-slot-value 2 R)");
cout<<theData1 <<endl;
}

i can see the result of theData1 is 1.77 from the screen, but i also
want to convert theData1 to double type of C++ in order to pass
theData1 to external C++ function to use. what should i do ?
Thanks!

Lode Hoste

unread,
May 29, 2012, 4:44:34 PM5/29/12
to clip...@googlegroups.com
HI Antangzhu,

Please read the advanced programming guide: 4.1.9 Eval.

<<<
int Eval(expressionString,&result);
Arguments:
1) A string containing the expression to be evaluated.
2) Caller’s buffer for storing the result of the evaluation. See
sections 3.2.3 and 3.2.4 for information on getting the value
stored in a DATA_OBJECT.
>>>

Once you have a DATA_OBJECT, you can easily get the double value.
Note that the documentation was for CLIPS (C) while you are using
CLIPSCPP but it should be more or less the similar.

2012/5/24 antangzhu <zhangyu...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
> To post to this group, send email to CLIP...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en
>
> --> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
> Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
> Click on "Edit my membership" link.
> Select the "No Email" radio button.
> Click the "Save these settings" button.
>
> --> IF YOU WANT TO UNSUBSCRIBE <--
> Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
> Sign in
> Click on "Edit my membership" link.
> Click the "Unsubscribe" button.
> Note: This appears to be the most reliable way to unsubscribe
>
> Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.
Reply all
Reply to author
Forward
0 new messages