Re: Please Help a student...
- To: mathgroup at smc.vnet.net
- Subject: [mg67423] Re: Please Help a student...
- From: "ragfield" <ragfield at gmail.com>
- Date: Fri, 23 Jun 2006 04:31:39 -0400 (EDT)
- References: <e7ds1a$9jc$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Kerekes Csaba - Antal wrote: > I'm a student in Romania, I study informatics. I use Mathematica > and I'm very satisfied with the product. I use it because I work in > the number field theory and experimental mathematics, where I need big number precision. I am now in my last year and I need to show my final project. > I have been written an algorithm in Mathematica, and I need to make a graphical user interface in MS Visual C++ 6.0. I have make the first step successfully I connected MS VC++6.0 with Mathematica via MathLink and I can call every function from Mathematica directly from my VC++ program. > Here comes my question: > I sad I can call every Mathematica function from VC++ via MathLink but what can I do to call my own written Mathematica function from VC++6.0? > Please Help I got my finals in one week, and by the university nobody can help me. I need to do my GUI in VC++ and I have not yet connected my own function written in Mathematica. > Please send be a good description in a short time: how to call in MS VC++6.0 via MathLink your own function written in Mathematica, or youre notebook file. Perhaps you could elaborate on what you have tried so far. Calling a user-defined function via MathLink is the same as calling a mathematica-defined function: MLPutFunction(theLink, "EvaluatePacket", 1); MLPutFunction(theLink, "MyUserFunction", theArgCount); ... or MLPutFunction(theLink, "EvaluatePacket", 1); MLPutFunction(theLink, "ToExpression", 1); MLPutString(theLink, "MyFunction[1, 2]"); You do need to make sure that your user function has been defined in Mathematica. If the code is relatively small, you could include it directly in your C/C++ source code: MLPutFunction(theLink, "EvaluatePacket", 1); MLPutFunction(theLink, "ToExpression", 1); MLPutString(theLink, "MyFunction[a_Integer, b_Integer] = a + b"); or if it is much larger, you can put it into a package (.m) file and load that file get Get/Needs: MLPutFunction(theLink, "EvaluatePacket", 1); MLPutFunction(theLink, "ToExpression", 1); MLPutString(theLink, "Needs[\"MyPackage`\"]"); MLPutFunction(theLink, "EvaluatePacket", 1); MLPutFunction(theLink, "ToExpression", 1); MLPutString(theLink, "MyFunction[1, 2]"); -Rob