Contents Previous Next Subchapters

Receiving Commands From an OMDDE Client
Source Files: winmain.c omdde.c dderror.c omdde.h

Prototype
int OMServerCmd(char *cmd)

Description
This routine is called when a command is sent from an OMDDE client to a server. (The client does this by calling OMClientPutCmd .) If the return value of OMServerCmd is TRUE, the server accepted the command. If the return value of OMServerCmd is FALSE, the server is currently busy and cannot execute the clients command.

Example
When linked with the program WinMain , the example below sets up a server that just prints the commands in its output window.

# 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)
{    return FALSE;
}
void OMServerOutput(enum type_mat *mtype, int *nr, int *nc, void *data)
{    *mtype     = UNDEF_mat;
     *nr        = 1;
     *nc        = 1;
     return;
}

void Setup()
{    
     int    ok;

     AddText("Demo OMServerCmd\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 omsercmd.exe
in the directory c:\omwin\omdde. If you then execute the command
     omsercmd
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("command", "x = y + z")
O-Matrix will respond
     T
and the server will respond
     OMServerCmd: Execution is requested for the command
     x = y + x