|
Contents | Previous | Next | Subchapters |
winmain.c omdde.c dderror.c omdde.h
int OMServerInput(
enum type_mat mtype,
int nr,
int nc,
void data
)
OMServerInput is TRUE,
the server accepted the matrix.
Otherwise, the return value is false and the server is
considered to be busy.
# include <stdio.h>
# include "define\omdde.h"
extern void AddText(char *add);
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)
{ int i, j, k;
char buf[100];
mbool *B;
mchar *C;
mint *I;
mreal *R;
mdbl *D;
AddText("OMServerInput:\n");
for(i = 0; i < nr; i++)
{ for(j = 0; j < nc; j++)
{ k = i + j * nr;
switch( mtype )
{ case LOGICAL_mat:
B = (mbool *) data;
if( B[k] )
AddText(" T");
else AddText(" F");
break;
case CHAR_mat:
C = (mchar *) data;
sprintf(buf, "%c", C[k]);
AddText(buf);
break;
case INT_mat:
I = (mint *) data;
sprintf(buf, " %10d ", I[k]);
AddText(buf);
break;
case REAL_mat:
R = (mreal *) data;
sprintf(buf, " %10.5f", R[k]);
AddText(buf);
break;
case DOUBLE_mat:
D = (mdbl *) data;
sprintf(buf, " %10.5f", D[k]);
AddText(buf);
break;
case COMPLEX_mat:
D = (mdbl *) data;
k = 2 * k;
sprintf(buf, " (%10.5f, %10.5f)", D[k], D[k+1]);
AddText(buf);
break;
default:
AddText("Invalid matrix type");
return FALSE;
}
}
AddText("\n");
}
AddText("\n");
return TRUE;
}
void OMServerOutput(enum type_mat *mtype, int *nr, int *nc, void *data)
{ *mtype = UNDEF_mat;
*nr = 1;
*nc = 1;
if( data == NULL )
AddText("OMServerOutput: data == NULL\n");
else AddText("OMServerOutput: data != NULL\n");
return;
}
void Setup()
{
int ok;
AddText("Demo OMServerInput\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 omserinp.exe
in the directory c:\omwin\omdde.
If you then execute the command
omserinp
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
x = seq(2) * seq(2)'
omlink("put", x)
O-Matrix will respond
T
and the server will respond
OMServerInput:
1 2
2 4
If you continue by entering
omlink("put", complex(x))
O-Matrix will respond
T
and the server will respond
OMServerInput:
( 1.00000, 0.00000) ( 2.00000, 0.00000)
( 2.00000, 0.00000) ( 4.00000, 0.00000)