Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: a mathlink question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89658] Re: a mathlink question
  • From: GS <vokaputs at gmail.com>
  • Date: Mon, 16 Jun 2008 06:42:29 -0400 (EDT)
  • References: <g32q5m$c2t$1@smc.vnet.net>

Thanks to everybody who answered my question.

After posting it, I found an example counter.c in the mathlink examples
directory of the Mathematica installation which does exactly what I need.
The trick is to define a global variable, and then its value is preserved
between the subsequent calls from Mathematica (as correctly pointed out
by Szabolcs Horv=E1t in his reply).

GS.

On Jun 15, 3:16 am, GS <vokap... at gmail.com> wrote:
> I would like to call a C-program from Mathematica. All the examples in
> the MathLink tutorials (like AddTwo[i,j]) work like this: they are
> called from Mathematica, are executed, send the result to Mathematica
> and exit.
>
> I would like a C-program to not exit after the execution, and keep the
> memory of the previous inputs. Say, I want an external C-program, to
> be called as AddToPreviousSum[x]. When it is first called, it returns
> x. When it is called the second time AddToPreviousSum[y], it returns x
> +y. When it is called the third time AddToPreviousSum[z], it returns x
> +y+z, and so on.
>
> How do I implement this in C using MathLink?
>
> Thanks.
> GS.



  • Prev by Date: Re: Mathematica Tutorials Format
  • Next by Date: Re: a mathlink question
  • Previous by thread: Re: a mathlink question
  • Next by thread: Re: a mathlink question