EasyManua.ls Logo

Galil DMC-4040 - Page 77

Galil DMC-4040
284 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Sending Commands in VB
Most commands are sent to the controller with the DMCCommand() function. This function allows any Galil
command to be sent from VB to the controller. The DMCCommand() function will return the response from the
controller as a string. Before sending any commands the DMCOpen() function must be called. This function
establishes communication with the controller and is called only once.
This example code illustrates the use of DMCOpen() and DMCCommand(). A connection is made to controller #1
in the Galil registry upon launching the application. Then, the controller is sent the command ‘TPX’ whenever a
command button is pressed. The response is then placed in a text box. When the application is closed, the controller
is disconnected.
To use this example, start a new Visual Basic project, place a Text Box and a Command Button on a Form, add the
DMCCOM40.BAS module, and type the following code:
Dim m_nController As Integer
Dim m_hDmc As Long
Dim m_nRetCode As Long
Dim m_nResponseLength As Long
Dim m_sResponse As String * 256
Private Sub Command1_Click()
m_nRetCode = DMCCommand(m_hDmc, "TPX", m_sResponse, m_nResponseLength)
Text1.Text = Val(m_sResponse)
End Sub
Private Sub Form_Load()
m_nResponseLength = 256
m_nController = 1
m_nRetCode = DMCOpen(m_nController, 0, m_hDmc)
End Sub
Private Sub Form_Unload(Cancel As Integer)
m_nRetCode = DMCClose(m_hDmc)
End Sub
Where:
‘m_nController’ is the number for the controller in the Galil registry.
‘m_hDmc’ is the DMC handle used to identify the controller. It is returned by DMCOpen.
‘m_nRetCode’ is the return code for the routine.
‘m_nResponseLength’ is the response string length which must be set to the size of the response string.
‘m_sResponse’ is the string containing the controller response to the command.
DMC-40x0 User Manual Chapter 4 Software Tools and Communication 68

Table of Contents

Related product manuals