| gclib 528 Communications API for Galil controllers and PLCs |

Message_Example.vb
1 Module Message_Example
2 Function Main() As Integer
3 Dim rc As Integer = Examples.GALIL_EXAMPLE_OK
4 Dim gclib As Gclib = New Gclib()
5 Dim args() As String = Environment.GetCommandLineArgs()
6 Try
7 If args.Count <> 2 Then
8 Console.WriteLine("Incorrect number of arguments provided")
9 Console.WriteLine("Usage: message_example.exe <ADDRESS>")
10
11 Console.Write(vbCrLf + "Press any key to close the example.")
12 Console.ReadKey()
13 Return Examples.GALIL_EXAMPLE_ERROR
14 End If
15
16 Dim address As String = args(1) 'Retrieve address from command line
17
18 ' Opens a connection at the provided address
19 ' The --subscribe MG addition Is needed to subscribe to
20 ' controller messages
21 gclib.GOpen(address + " --subscribe MG")
22
23 rc = Examples.Message(gclib)
24 Catch ex As Exception
25 Examples.PrintError(gclib, ex)
26 rc = Examples.GALIL_EXAMPLE_ERROR
27 Finally
28 gclib.GClose()
29 End Try
30
31 Console.Write(vbCrLf + "Press any key to close the example.")
32 Console.ReadKey()
33
34 Return rc
35 End Function
36 End Module