10. Examples

10.1. Lpe object

Visual Basic 6 example:

' Suppose the scales has IP address 192.168.0.112:8111
Set o = CreateObject("Scales.Lpe")
ret = o.Connect("192.168.0.112", 8111)
If ret = 0 Then
  GoTo ErrorLabel
End If
' Enter data to send into the scales
o.Name1 = "Cheese"
o.GoodsCode = 123456
o.GoodsPrice = 9.95
' Send data to the item #500 in the scales #1
o.Send 1, 500
' Retrieve item data from the scales
o.Recieve 1, 500
Debug.Print o.Name1, o.GoodsCode, o.GoodsPrice
o.Disconnect
Set o = Nothing

10.2. LpeWeigh object

Visual Basic 6 example:

' Use code like the following in your form

Private WithEvents o As LpeWeigh
 
Private Sub o_Weighed()
    Debug.Print "The weight is", o.StateWeight
End Sub

1C:Enterprise 7.7 example with Universal 1C LanguageExtender:

// Initialization
AttachAddIn("AddIn.ULE");
Scales = CreateObject("AddIn.ULE");
Scales.TransmuteIntoWithEvents2("Scales.LpeWeigh", 
  "742B3B6D-86D9-416B-A505-A0F89E4FCA17,1000", "Weight");

// In your form
Procedure ExternEventProcessing(Source, Event, Data)
If Event = "Weighed" Then              
 CurrentWeight = Scales.StateWeight;
EndProcedure

10.3. Vpt object

Visual Basic 6 example:

' Suppose that scales is connected to COM2 port
Set o = CreateObject("Scales.Vptip")
ret = o.Connect("", 2)
If ret = 0 Then
  GoTo ErrorLabel
End If
' Enter data to send into the scales
o.Name1 = "Cheese"
o.GoodsCode = 123456
o.GoodsPrice = 9.95
' Send data to the item #500 in the scales #1
o.Send 1, 500
' Retrieve item data from the scales
o.Recieve 1, 500
Debug.Print o.Name1, o.GoodsCode, o.GoodsPrice
o.Disconnect
Set o = Nothing

10.4. Vptip object

Visual Basic 6 example:

' Suppose that scales server is running on the localhost
Set o = CreateObject("Scales.Vptip")
ret = o.Connect("127.0.0.1", 4567)
If ret = 0 Then
  GoTo ErrorLabel
End If
' Enter data to send into the scales
o.Name1 = "Cheese"
o.GoodsCode = 123456
o.GoodsPrice = 9.95
' Send data to the item #500 in the scales #1
o.Send 1, 500
' Retrieve item data from the scales
o.Recieve 1, 500
Debug.Print o.Name1, o.GoodsCode, o.GoodsPrice
o.Disconnect
Set o = Nothing