Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Emulating Visual Basic Character Arrays
Message
From
05/05/2004 11:11:57
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Emulating Visual Basic Character Arrays
Miscellaneous
Thread ID:
00901211
Message ID:
00901211
Views:
83
Hello All,

I'm currently trying to create a VFP wrapper around a DLL that was designed specifically for Visual Basic. (Using VFP 6.0 sp5 on Win2K)

95% of the DLL functions perfectly within VFP.

I have, however, reached a stumbling block. One function of the DLL is expecting two parameters that I cannot seem to produce in Visual FoxPro. Luckily the DLL ships with examples for Visual Basic. The parameters are passed as character arrays in Visual Basic.

The code to declare these variables in Visual Basic (version 6.0 sp5) is:

' Input data type. 7 lines of 50 characters each.
Type INPTYPE
InputLine(6) As String * 50
End Type

' Output data type. 10 Lines of 100 characters each
Type OUTTYPE
OutputLine(10) As String * 100
End Type

' Global structures used for function
Public gInputType As INPTYPE
Public gOutputType As OUTTYPE

The code in Visual Basic that calls the function looks like this:

Declare Function MY_Function Lib "mylib.dll" ( _
InputType As INPTYPE, OutputType As OUTYPE

Return% = MY_Function(gInputType, gOutputType)

Once the function is called, gOutputType is populated with a range of results.

I've tried a number of things in VFP. When dimensioning VFP arrays of the required element count/string size I receive Fatal Exceptions. When I use padded strings to create buffers (REPLICATE(CHR(0), 50*7)) the function appears to function without error but nothing is populated in the output parameter.

I believe what I need to do is emulate the Visual Basic Character arrays within VFP... and so my question is: Can it be done, and if so, can anybody point me in teh right direction?

I've trawled through the struct.vcx but cannot seem find anything that might help.

Any advice would be much appreciated.

Thanks in advance for any advice provided.

Kind Regards,

Ben Sugden
Ben Sugden

"Remember to enjoy hunting - and that means relishing the search for the product that has never been advertised or placed handily at the front of the shop; Life begins on the uppermost shelf, avoid guide books and top 10's like the plague." - Ramsey Dukes
Next
Reply
Map
View

Click here to load this message in the networking platform