|
Contents | Previous | Next | Subchapters |
winmain.c omdde.c dderror.c omdde.h
void OMServerOutput(
enum type_mat *mtype,
int *nr,
int *nc,
void *data
)
UNDEF_mat in which case the server does
not yet have a matrix to send to the client.
The output value of nr specifies the number of
rows in the matrix.
The output value of nc specifies the number of
columns in the matrix.
If the input value of data is equal to NULL, the elements
of the matrix are not returned. This call is be used by the
client to find out the size of the matrix.
If the input value of data is not equal to NULL,
it points to
OMSize(mtype)
times nr times nc
bytes of memory where
mtype, n, and nc correspond to the
previous call to OMServerOutput.
In this case, the elements of the matrix are be placed in the
memory pointed to by data.
This elements will be in column major order; i.e., the first column
followed by the second etc.
NULL.
# include <stdio.h>
# include "define\omdde.h"
extern void AddText(char *add);
static int Count = 1;
int OMServerCmd(char *cmd)
{ AddText("OMServerCmd: Execution is requested for the command\n");
AddText(cmd);
return TRUE;
}
int OMServerInput(enum type_mat mtype, int nr, int nc, void *data)
{ return FALSE;
}
void OMServerOutput(enum type_mat *mtype, int *nr, int *nc, void *data)
{ int i;
mint *ptr;
*mtype = INT_mat;
*nr = 1;
*nc = Count;
if( data == NULL )
{ AddText("OMServerOutput: data == NULL\n");
return;
}
AddText("OMServerOutput: data != NULL\n");
ptr = (mint *) data;
for(i = 0; i < Count; i++)
ptr[i] = i + 1;
Count++;
return;
}
void Setup()
{
int ok;
AddText("Demo OMServerOutput\n");
ok = OMDdeInitialize();
if( ! ok )
{ AddText("Cannot initialize OMDDE\n");
return;
}
ok = OMServerRegister("C-Server");
if( ! ok )
{ AddText("Cannot register server\n");
OMDdeUninitialize();
return;
}
}
void ShutDown()
{
OMDdeUninitialize();
return;
}
If you have the Microsoft Visual C++ compiler, you can compile
and link this example by executing the command
nmake /f windows.mak omserout.exe
in the directory c:\omwin\omdde.
If you then execute the command
omserout
then run a copy of O-Matrix,
and at the O> prompt you enter
omlink("client", "C-server")
O-Matrix will respond
T
If you continue by entering
omlink("get")
O-Matrix will respond
1
and the server will respond
OMServerOutput: data == NULL
OMServerOutput: data != NULL
If you continue by entering
omlink("get")
O-Matrix will respond
[ 1 , 2 ]
and the server will respond
OMServerOutput: data == NULL
OMServerOutput: data != NULL