Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DECLARE enigma with the Boolean type

Status
Not open for further replies.

dkean4

Programmer
Feb 15, 2015
282
US
I purchased a little controller board from Velleman K8055. It is designed to work with a DLL and here is an incomplete list of Declarations written in Visual Basic, to access the board.

Code:
Private Declare Function Version Lib "k8055d.dll" () As Long
Private Declare Function SearchDevices Lib "k8055d.dll" () As Long
Private Declare Function SetCurrentDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long

Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (Data1 As Long, Data2 As Long)
Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long, ByVal Data As Long)
Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As Long)
Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)
Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long) As Boolean
Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Long
Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As Long
Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)
Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByVal DebounceTime As Long)
Private Declare Function SetTimer Lib "user32" ( _
    ByVal HWnd As Long, ByVal nIDEvent As Long, _
    ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" ( _
    ByVal HWnd As Long, ByVal nIDEvent As Long) As Long

I have successfully converted some and I cannot convert others to work properly in VFP. The lines in red are resisting me by not returning values.

Code:
DECLARE Integer OpenDevice IN k8055d.dll Integer CardAddress
DECLARE SetDigitalChannel IN k8055d.dll Integer Channel
[COLOR=#CC0000]DECLARE Integer ReadDigitalChannel IN k8055d.dll integer Channel[/color]
DECLARE ClearDigitalChannel IN k8055d.dll integer Channel
[COLOR=#CC0000]DECLARE Integer [COLOR=#CC0000]ReadAllDigital[/color] IN k8055d.dll[/color][COLOR=#CC0000][/color]
DECLARE CloseDevice IN k8055d.dll
DECLARE ClearAllDigital IN k8055d.dll

The problem appears to be simple. In VB these Declarations are defined as Functions. Dennis however is using the "Integer" type. VFP does not have the Boolean option and after a million tests I was able to get a result for the OpenDevice Declaration to return a 0 to me, which indicates that the device was opened. That works great and reliably. The other Function declarations, however set the return value to Boolean and VFP does not have a Boolean option. What can I do there?

Some of you guys may have lots more experience with DLLs and Declarations than me. Any help is appreciated...



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Do what I did, use double pole relays and feed the results back to your actuall inputs as feedback, so if output 1 is up, so is input 1

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
That makes your timer about as expensive as my thermostat was!


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Good idea, Griff... Thanks...

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top