MathGroup Archive 2000

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

Search the Archive

Re: Further question on "I have nested lists of ints....."

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22838] Re: Further question on "I have nested lists of ints....."
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 1 Apr 2000 02:51:00 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <8c1hfd$q49@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Jamie,

it can't work. You need a recussive function to read your data
structure. 


Expression *ReadExpression(MLINK link)
{ Expression *e;
  int n;

  switch(MLGetNext(link)) {
      case MLTKFUNC:
        MLGetArgCount(link, &n);
        e=NewExpression(link,n);  /* this include 
            a recursive call to ReadExpression() to
            scan the head */         
        for (i = 0; i < n; i++)
          InsertAt(e,i, ReadExpression(link));
        break;

   /* handel int's doubles and symbols */
  }
  return e;
}
      
But neither ReadExpression() nor NewExpression() should call
back to Mathematica !!!

It is up to you to think how struct/class Expression should
look like ! and what NewExpression() does.

Hope that helps
  Jens

"Jamie B. McHardy" wrote:
> 
> Jens-Peer Kuska has informed me that must use MLGetNext etc in order to
> get the information over.  I have this problem though, the function
> "SendDataToC" for example,
> 
> int SendDataToC( void )
> {
>      int n, pkt;
> 
>      /* Send "LinkBuffer"
>         this holds the data that is needed in C,  Refer to the original
> question...
>       */
>      MLPutFunction( stdlink , "EvaluatePacket", 1L);
>           MLPutSymbol( stdlink, "LinkBuffer\0");
>      MLEndPacket( stdlink );
> 
>      /* skip any packets before the first ReturnPacket */
>      while( (pkt = MLNextPacket( stdlink ), pkt) && pkt != RETURNPKT) {
>             MLNewPacket( stdlink );
>             if( MLError( stdlink )) error( stdlink );
>      }
> 
>      MLGetArgCount(stdlink, &iArgCount);
>      while( iArgCount-- )
>      {
>             /* read_element is a function that uses switch with
>                 MLGetNext(...) to cope with all types of data in the
> structure
>                 being sent over
>                 All this is modified from the factor3.c in the
> mathematica
>                 example programs*/
>             read_element( stdlink );
>      }
> }
> 
> This just doesn't work.
> 
> I have tried this in many different ways, including having manual in the
> Template file and then trying to get it over that way.
> 
> What is wrong with this method? is it possible to get this data over?
> how would I go about doing it.  There seems to be no information  on how
> to get non uniform data over a mathlink that is calling an application
> from within Mathematica.
> 
> Many thanks in advance.
> 
> Jamie


  • Prev by Date: Selecting a subsection cell
  • Next by Date: Eigensystem Error on Machine Precision Matrices
  • Previous by thread: Selecting a subsection cell
  • Next by thread: Eigensystem Error on Machine Precision Matrices