Applies To:
  • CitectSCADA 1.00 1.01 1.10 1.11 1.20 2.00 2.01 3.00

Summary:
Do you have some example code on how I use the Msg functions? 

Solution:
Yes here is an example of using the message functions.

/*
** This code will open a connection to the alarms server from
** the client side and call a remote function. The client will
** call the Prompt function remotely. The prompt function will
** execute on the alarm server and display "Hello Alarm Server"
** on the prompt line.
*/

FUNCTION
HelloAlarm ( )
   INT hAlarm;

   hAlarm=MsgOpen("Alarm", 0, 0);
   IF hAlarm >=0 THEN
      MsgRPC(hAlarm, "Prompt", "^"Hello Alarm Server^"", 1);
   ELSE
      Prompt("Cannot Open to Alarm Server");
   END
END

/*
** This code will open a connection to a client from the
** server side and call a remote function. The name of
** the client is set in the CITECT.INI as below:
**
** [Lan]
** Name=Machinel
**
** The alarm server will call the prompt function remotely. The
** prompt function will execute on the client machine called
** "Machinel" and display "Hello Machinel" on the prompt line.
**
** Note you must use mode 2 with the MsgOpen function to specify
** the exact client computer. If you use mode 1 this will tell
** the open to connect the function to all clients and the
** returned message number cannot be used with MsgRPC.
*/

FUNCTION
HelloClient ()
   INT hClient;

   hClient=MsgOpen("Machinel", 2, 0);
   IF hClient>=0 THEN
      MsgRPC(hClient, "Prompt", "^"Hello Machinel^"", 1);
   ELSE
      Prompt("Cannot Open to Machinel");
   END
END


Keywords:
 

Attachments