MathGroup Archive 2002

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

Search the Archive

Re: MathLink and Notebooks

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37541] Re: MathLink and Notebooks
  • From: "Lawrence A. Walker Jr." <lwalker701 at earthlink.net>
  • Date: Mon, 4 Nov 2002 02:44:06 -0500 (EST)
  • Organization: Morgan State University, COMSARE
  • References: <apva81$rh5$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Cesar,

Try the following

MLNextPacket(stdlink); // drain packet
MLNewPacket(stdlink);  // discard packet

Instead of ...

MLEndPacket(stdlink);
MLFlush(stdlink);
MLNewPacket(stdlink);

For more info, refer to Todd Gayley's, A Mathlink Tutorial (perhaps on 
MathSource).

Lawrence


Cesar Guerra wrote:
> Hi MathGroup,
> 
> Working with MathLink and Mathematica functions to manipulate notebooks I had the following problem
> 
> I tried to make a MathLink function which before giving the final result, it sends to mathematica information about how the process is going on ( for example convergence of a variable or an index in a loop). The point is that printing all this could be very long ( a file is better in this case ) and I wanted a cell which is edited and deleted as the process goes on. The following function is a model of what iI intented
> 
> /*******************************************************************/
> 
> :Begin:
> :Function:        test
> :Pattern:         test[]
> :Arguments:       {}
> :ArgumentTypes:   {}
> :ReturnType:      Integer
> :End:
> 
> /********************************************************************/
> 
> int test()
> {
>    int i,j;
> 
> for ( i=0;i<100 ;i++ )
> {       /* Sending the variable i to be displayed in Mathematica */
>       MLPutFunction(stdlink,"EvaluatePacket",1);
>                MLPutFunction(stdlink,"CompoundExpression",2);
>                         MLPutFunction(stdlink,"NotebookWrite",3);
>                              MLPutFunction(stdlink,"SelectedNotebook",0);
>                              MLPutFunction(stdlink,"Cell",2);
>                                      MLPutFunction(stdlink,"ToString",1);
>                                            MLPutInteger(stdlink,i);
>                                      MLPutString(stdlink,"Program");
>                              MLPutSymbol(stdlink,"All");
> 
>                         MLPutSymbol(stdlink,"Null");
>       MLEndPacket(stdlink);
>       MLFlush(stdlink);
>       MLNewPacket(stdlink);
> }
> 
>      /* This is the final answer */
>      return 0;
> }
> /********************************************************************/
> 
> The function works fine until leaving the for loop. After that the link is lost. I can't fix this problem, I suppose that I don't treat the return packets in a proper way. I would be very greateful for any hints about this
> 
> Best regards......
> 
> Cesar 
> 
> 
> 


-- 
Lawrence A. Walker Jr.
http://www.kingshonor.com


  • Prev by Date: Re: Rember Palette Position
  • Next by Date: Re: Tensors in Mathematica
  • Previous by thread: Re: Rember Palette Position
  • Next by thread: Re: Combination/Permutation questions