gclib  2.0.8
Communications API for Galil controllers and PLCs
IP_Assigner_Example.vb
Go to the documentation of this file.
1 Module IP_Assigner_Example
2 
3  Function Main() As Integer
4  Dim rc As Integer = Examples.GALIL_EXAMPLE_OK
5  Dim gclib As Gclib = New Gclib()
6  Dim args() As String = Environment.GetCommandLineArgs()
7  Try
8  If args.Count() <> 3 Then
9  Console.WriteLine("Incorrect number of arguments provided")
10  Console.WriteLine("Usage: ip_assigner_example.exe <SERIAL #> <1 Byte Address>")
11 
12  Console.Write(vbCrLf + "Press any key to close the example.")
13  Console.ReadKey()
14  Return Examples.GALIL_EXAMPLE_ERROR
15  End If
16 
17  Dim serial_num As String = args(1)
18  Dim address As Byte
19  Dim ok As Boolean = Byte.TryParse(args(2), address)
20 
21  If Not ok Then
22  Console.WriteLine("Please enter a number between 0 and 255 for the address.\n" +
23  " This will be used as the last number in the IP Address\n" +
24  "Usage: ip_assigner_example.exe <SERIAL #> <1 Byte Address>")
25 
26  Console.Write(vbCrLf + "Press any key to close the example.")
27  Console.ReadKey()
28  Return Examples.GALIL_EXAMPLE_ERROR
29  End If
30 
31  rc = Examples.IP_Assigner(gclib, serial_num, address)
32  Catch ex As Exception
33  Examples.PrintError(gclib, ex)
34  rc = Examples.GALIL_EXAMPLE_ERROR
35  Finally
36  gclib.GClose()
37  End Try
38 
39  Console.Write(vbCrLf + "Press any key to close the example.")
40  Console.ReadKey()
41 
42  Return rc
43  End Function
44 
45 End Module
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
Definition: gclib.cs:68
int Main()
partial Module Examples
Definition: Commands.vb:4