OBSOLETE WSTP C FUNCTION

MLBytesToPut()
This feature is not supported on the Wolfram Cloud.

has been replaced by .

int MLBytesToPut(MLINK link,int *n)
calculates the number of bytes remaining to be written in the textual representation of the current data, and stores the result in n.

DetailsDetails

  • MathLink provides functions such as MLPutString(), MLPutSymbol(), MLPutInteger32(), and MLPutReal64() for sending strings, symbols, integers, and floating-point numbers. However it is sometimes convenient to send these types using a character string representation. MLBytesToPut() works with MLPutType(), MLPutRawSize() and MLPutRawData() to send a type using a character string representation.
  • MLBytesToPut() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLBytesToPut() fails.
  • MLBytesToPut() is declared in the MathLink header file mathlink.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include <string.h>
#include "mathlink.h"

/* send an approximation of Pi across a link */

void f(MLINK lp)
{
    char *Pi = "3.141592654";
    int bytes_left, i;

    if(! MLPutType(lp, MLTKOLDREAL))
        { /* unable to send the data type to lp */ }

    if(! MLPutRawSize(lp, strlen(Pi))
        { /* unable to send the length of Pi to lp */ }

    if(! MLBytesToPut(lp, &bytes_left))
        { /* unable to get the remaining bytes to send from lp */ }

    i = 0;
    while(bytes_left > 0)
    {
        /* send the data one byte at a time */
        if(! MLPutRawData(lp, Pi + i, 1))
            { /* unable to send a character of Pi to lp */ }

        if(! MLBytesToPut(lp, &bytes_left))
            { /* unable to get the remaining bytes to send from lp */ }

        i++;
    }
}