Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

MathLink and Notebooks

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37407] MathLink and Notebooks
  • From: Cesar Guerra <guerra_cesar at yahoo.com>
  • Date: Sat, 26 Oct 2002 02:04:36 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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 




  • Prev by Date: Re: Off by 0.00000001, Why?
  • Next by Date: Re: HelpBrowser Mathematica Book 1.8.3 on Linux
  • Previous by thread: $RecursionLimit
  • Next by thread: Approximation of complex solutions