Hi Ed, thanks for your reply.
I'm sad to see how BIG problems this is giving me when I at the same time (with very little knowledge in VB) can see how easy it's done with VB.
I hope it is possible to do with VFP ( I think I am getting mad by all these new words like structure, pointer etc ). I really would like to get TYPEs in VFP.
The DRV_GetAddress function is always returning an integer value. So to be able to send either an string or an numeric variable reference i redeclared the DRV_GetAddress a second
time with the alias of DRV_GetAddress_INT ( as you can se in the VFP code below ).
The DeviceHandle-parameter in the code is an integer recieved in an earlier DLL-call (DRV_DeviceOpen)
VB code:
** In modul Driver.bas:
Type PT_DioReadPortByte
Port As Integer
value As Long ' USHORT far *value
End Type
** In modul Global.bas:
Global lpDioReadPort As PT_DioReadPortByte
***************
Private Sub cmdRead_Click()
Dim DiValue As Integer
** The following line returns an integer value .
lpDioReadPort.value = DRV_GetAddress(DiValue)
**Now lpDioReadPort.value can be something like 1242510. Is this the addresslocation of variable DiValue ?
** Right now the value in the variable DiValue is 0
** The next line changes the value in DiValue ( if there is any insignal to the I/O card).
ErrCde = DRV_DioReadPortByte(DeviceHandle, lpDioReadPort) && here the lpDioReadPort must be providing this function with
End Sub
****************
This works perfect in VB, but i can not get the value in variable DiValue to change in VFP.
Can it be something wrong with my setup of the structure lpDioReadPort ?
****************
*My VFP code:
DECLARE INTEGER DRV_GetAddress IN adsapi32.dll as DRV_GetAddress_INT;
INTEGER @ lpVoid
DEFINE CLASS MyStruct_PT_DioReadPortByte AS Struct && Struct.vcx
port = 0
varde = 0
cMembers = " l:port, l:varde "
ENDDEFINE
lpDioReadPort = CREATE("MyStruct_PT_DioReadPortByte")
DiValue=0
tmpstr = ""
** The following line returns an integer value .
lpDioReadPort.varde = DRV_GetAddress_INT(@ DiValue)
tmpstr = lpDioReadPort.GetString()
** The next line does not change the value in variable DiValue as it does in VB.
ErrCde = DRV_DioReadPortByte( DeviceHandle,@ tmpstr )
***********************************
Ed, perhaps you think that i send to much code to you, and if so please tell me.
If someone else want to jump in here, your wellcome.
Torgny
/Torgny