Contents Previous Next Subchapters

Transferring Data From OMDDE Client to Server

Prototype
char *OMClientPutMat(
     int            
id,
     enum type_mat  
mtype,
     int            
nr
     int            
nc,
     void          *
data
)


Description
This function call transfers a matrix from a client to a server. The argument id is the integer index returned by a previous call to OMClientConnect . It specifies which server the matrix is being sent to. The argument mtype specifies the type of the matrix and must be one of the following: LOGICAL_mat,INT_mat,REAL_mat,DOUBLE_mat,COMPLEX_mat,CHAR_mat. The argument nr is an integer specifying the number of rows in the matrix. The argument nc is an integer specifying the number of columns in the matrix. The argument data is a pointer to the data in the matrix. This data must be in column major order; i.e., the first column followed by the second etc. If the return value is equal to "ok", the matrix was accepted. If the return value is equal to "busy", the server is currently busy and cannot accept the matrix.

Example
The following example prints the double-precision matrix
     / 1  3 \
     \ 2  4 /
in the Command window of a currently running copy of O-Matrix. It is in the file omcliput.c in the directory omwin\omdde. If you have the Microsoft Visual C++ compiler, it can be compiled and linked by executing the command
     nmake /f console.mak omcliput.exe
in that directory.

# include <stdio.h>
# include "define\omdde.h"
# include "define\noserver.h"

int main()
{    
     int            id;
     char           *msg;           
     enum type_mat  mtype  = DOUBLE_mat;
     int            nr     = 2;
     int            nc     = 2;
     mdbl           data[] = {1., 2., 3., 4.};
     char           *cmd   = "print omlink(\"get\")";
     
     int ok;

     ok = OMDdeInitialize();
     if( ! ok )
     {    printf("Cannot initialize OMDDE\n");
          return 1;
     }

     id = OMClientConnect("O-Matrix");
     if( id == OMDDE_CONNECTION_FAILED ) 
     {    printf("Cannot connect to O-Matrix\n");
          return 1;
     }

     msg = OMClientPutMat(id, mtype, nr, nc, data);
     printf("Matrix transfer result = %s\n", msg);
     
     msg = OMClientPutCmd(id, cmd);
     printf("Command transfer result = %s\n", msg);

     OMDdeUninitialize();

     return 0;
}

Reference
Invalid memory will be accessed if id is not equal to a previous return value of OMClientConnect.