MathGroup Archive 2003

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

Search the Archive

Re: MathLink: how do I wrap and call a subroutine that should return nothing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39010] Re: [mg38980] MathLink: how do I wrap and call a subroutine that should return nothing
  • From: Omega Consulting <info at omegaconsultinggroup.com>
  • Date: Fri, 24 Jan 2003 05:06:37 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Even when the ReturnType is Manual, your C function needs to send 
something. It can really be anything, as long as it's a complete 
expression. For example, you could do

/* send Print["Done"] to kernel */
MLPutFunction(stdlink, "Print", 1);
MLPutString(stdlink, "Done");

Now SetValue will print "Done". But since you probably don't want anything 
from SetValue, you should send the symbol Null.

MLPutSymbol(stdlink, "Null");

Null is an output that's automatically suppressed, so you won't see an 
output cell.

At 07:05 AM 1/23/2003, Matthew D. Langston wrote:
>How do I wrap and call a C subroutine that should return nothing back to
>Mathematica. I want to somehow specify a :ReturnType: of "None" or "Void",
>but mprep doesn't recognize those tokens. If I specify "Manual" then my
>Mathematica session just hangs waiting for an answer from my MathLink
>program. Does MathLink have a function like MLPutEmptyPacket() that just
>tells Mathematica "Expect nothing from this MathLink function. It's OK to
>stop waiting and return to your command loop".
>
>This is (part of) the template file I am using:
>
>
>:Begin:
>:Function: SetValue
>:Pattern: SetValue[ value_?NumericQ ]
>:Arguments: {value}
>:ArgumentTypes: {Real}
>:ReturnType: Manual
>:End:
>
>void SetValue ( double value )
>{
>     /*
>      * Do something useful with value.
>      * It doesn't make sense to return anything.
>      */
>
>     /* What goes here to keep Mathematica from hanging? */
>}
>
>
>How do I specify a true MathLink subroutine that doesn't return a value to
>Mathematica? Thank you for your help.
>
>Warmest regards, Matt

--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"
http://omegaconsultinggroup.com



  • Prev by Date: Re: MathLink: how do I wrap and call a subroutine that should return nothing
  • Next by Date: Re: Modular Arithmetic Problem?
  • Previous by thread: Re: MathLink: how do I wrap and call a subroutine that should return nothing
  • Next by thread: FilledPlot Question