Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem communicating with Digital I/O Card
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00395294
Message ID:
00396131
Vues:
12
>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.
>

Then why not write it in VB? You can access VFP tables from a VB program using ODBC.

>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)
>

I'd recommend you get in touch with Christof Lange, who wrote STRUCT. I don't know what's going on inside the library you're using, and don't know what values are being associated with various fields. If any of the values stored are pointers to string space in VFP, they aren't going to remain static, and will invalidate themselves whenever VFP rearranges the string space, which is why I use static memory blocks for structure construction in CLSHEAP. I do not know what Christof does internally. In addition, if the DRV_GetAddress is relying on retrieving a pointer to a function using the AddressOf construct in VB, there's no direct equivalent pointer to function mechanism in VFP; you'd have to write something in another language that can publish it's entrypoints.

>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
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform