Tipp für Übersetzung aus VB in PB
Verfasst: 04.04.2006 18:22
Hallo
Als Anfänger eine gewagte Aktion, aber ich habe einen Vellemann USB-Datenlogger mit DLL für eigene Entwicklungen. Die Beispiele im Handbuch sind natürlich nur in VB und Delphi.
Das Abfragen der Speicheradressen der DLL-Funktionen klappt soweit. Ich weiss nur nicht, wie ich die Datenabfrage mit der Funktion readdata in Purebasic realisieren, bzw. aus VB nach PB übertragen soll. Hat jemand einen Tipp für mich?
Gruß
Ralf
Visual Basic Beispielprogramm
und hier mein Programmschnipsel in Purebasic
Als Anfänger eine gewagte Aktion, aber ich habe einen Vellemann USB-Datenlogger mit DLL für eigene Entwicklungen. Die Beispiele im Handbuch sind natürlich nur in VB und Delphi.
Das Abfragen der Speicheradressen der DLL-Funktionen klappt soweit. Ich weiss nur nicht, wie ich die Datenabfrage mit der Funktion readdata in Purebasic realisieren, bzw. aus VB nach PB übertragen soll. Hat jemand einen Tipp für mich?
Gruß
Ralf
Visual Basic Beispielprogramm
Code: Alles auswählen
Option Explicit
'Declare use of the DLL
'K8047D.DLL interface
'GENERAL PROCEDURES
Private Declare Sub StartDevice Lib "k8047d.dll" ()
Private Declare Sub StopDevice Lib "k8047d.dll" ()
Private Declare Sub LEDon Lib "k8047d.dll" ()
Private Declare Sub LEDoff Lib "k8047d.dll" ()
'INPUT PROCEDURE
Private Declare Sub ReadData Lib "k8047d.dll" (Array_Pointer As Long)
'OUTPUT PROCEDURE
Private Declare Sub SetGain Lib "k8047d.dll" (ByVal Channel_no As Long, ByVal Gain As Long)
'Declare variables
Dim DataBuffer(0 To 7) As Long
Private Sub Check1_Click()
If Check1.Value = 1 Then LEDon Else LEDoff
End Sub
Private Sub Form_Load()
StartDevice
End Sub
Private Sub Form_Terminate()
StopDevice
End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim s As String
ReadData DataBuffer(0)
s = ""
For i = 0 To 5
s = s + Str(DataBuffer(i)) + Chr(9)
Next i
List1.AddItem s
End Sub
Private Sub Option1_Click(Index As Integer)
SetGain 1, Index
End Sub
Private Sub Option2_Click(Index As Integer)
SetGain 2, Index
End Sub
Private Sub Option3_Click(Index As Integer)
SetGain 3, Index
End Sub
Private Sub Option4_Click(Index As Integer)
SetGain 4, Index
End Sub
Code: Alles auswählen
If OpenLibrary(0, "K8047D.DLL")
ledoff=IsFunction(0, "LEDoff")
ledon=IsFunction(0, "LEDon")
readdata=IsFunction(0, "ReadData")
setgain=IsFunction(0, "SetGain")
start=IsFunction(0, "StartDevice")
stop=IsFunction(0, "StopDevice")
Debug ledoff
Debug ledon
Debug setgain
Debug readdata
Debug start
Debug stop
EndIf
CloseLibrary(0)
End