In the last post, I introduced Intercom with an old example I wrote using VB6. This post will be a much more modern example using C#.
I’ve also included a “Round Trip” example where the command is initiated via CC3. By adding this small macro, you now have a command that draws a diamond on the screen.
Code Snippet
- MACRO DIAMOND
- GP TEMP ^DCenter:
- SENDM 2 TEMP
- ENDM
What this does is as the user to get a point (GP) and then send it via Intercom to the c# application.
Once it gets to the c# code, it takes the string from CC3 (all data sent from CC3 via Intercom is in strings), splits it on the comma and converts the two substrings into doubles. Then it creates a command string and passes it back to CC3.
Code Snippet
- var strNumbers = System.Text.Encoding.ASCII.GetString(bytMsg).Split(‘,’);
- var x = double.Parse(strNumbers[0]);
- var y = double.Parse(strNumbers[1]);
- var strDiamond = “LINE \n” +
- (x – 100) + “,” + y + ” \n” +
- x + “,” + (y – 100) + ” \n” +
- (x + 100) + “,” + y + ” \n” +
- x + “,” + (y + 100) + ” \n” +
- (x – 100) + “,” + y + ” \n\n” +
- “ENDM”;
- icSendMsg(20, strDiamond);
Here is a link to the C# portion