Embedding Python in Borland C++ Application
bigjoe615 at my-deja.com
bigjoe615 at my-deja.com
Wed May 3 18:43:52 EDT 2000
I guess I will answer that...
...
PyObject* mathModule = PyImport_ImportModule("math");
PyObject* mathDict = PyModule_GetDict(mathModule);
PyObject *s;
String result = 0;
s=PyRun_String(exp.c_str(),eval_input,mathDict,mathDict);
PyObject* so =PyObject_Str(s);
result=PyString_AsString(so);
ShowMessage("Value of expression:"+result);
...
In article <8enfcr$u9d$1 at nnrp1.deja.com>,
bigjoe615 at my-deja.com wrote:
> I have been able to compile and link a C++
> (Borland C++ Builder 4.0) with Python 1.5.2.
>
> I can use the following code to evaluate simple
> arithmetic expressions (like 9*9):
>
> ...
> PyObject *s;
> PyObject *PyGlobal=PyDict_New();
> AnsiString exp=mFormulaTextDBMemo->Text;
> // struct _node*pn=PyParser_SimpleParseString
> (exp.c_str(),Py_single_input) ;
> s=PyRun_String(exp.c_str
> (),eval_input,PyGlobal,PyGlobal);
> total=PyInt_AsLong(s);
> ShowMessage("Value of expression:"+FloatToStr
> (total));
> ...
>
> I am trying to understand how to use built in
> functions like sqrt, pow, etc. PyRun_String
> does not seem to work. How would I do this?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list