Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to pass a byte array to a VFP COM server
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01504853
Message ID:
01504891
Views:
107
As a test, I decided to change the data type of the array that I am passing to char instead of byte, and use COMARRAY(..., 11). I had been using COMARRAY all along. So, I don't think that is the difference. In any case, this appears to work.

But, will it work without COMARRAY in a C++ client?

Any other thoughts or suggestions?
Thanks,
Jim


>What am I doing wrong??
>
>Here is a link to an MSDN example that addresses this
>
>
>http://msdn.microsoft.com/en-us/library/aa979305(v=vs.71).aspx
>
>
>It creates an array of doubles, calls a VFP COM server to calculate the determinant. It looks to me that I am doing a very analogous thing.
>
>
>
>>In other parts of my COM server, I pass parameters by reference. Here is another procedure in the server that works fine both from VFP and C++ clients:
>>
>>
>>PROCEDURE GetDatFilesFromvFBDPatVisits(sFBDDataSource AS String , nPatientNo AS Integer @, nVisitID as Integer @, ;
>>		nFileID AS Integer @, sFilename AS String @) 
>>
>>
>>And, I call this by
>>
>>Result = Thisform.oNPVD.GetDatFilesFromFBDPatVisits("FBD on JIM", @nPatientNo, @nVisitID, @nFileID, @cFilename)	
>>
>>
>>But, none of these are byte arrays.
>>
>>
>>>In VFP you need to call it by reference, e.g.
>>>
>>>DIMENSION aBlobData[nFileSize] AS Byte
>>>thisform.oNPVD.GetvFBDBlob(nFileID, @aBlobData) -- array populated with .F. at present
>>>
>>>However, I think there may be problems related with COM and passing parameters by reference - I don't recall right now.
>>>
>>>>>>Naomi,
>>>>>>
>>>>>>Thanks for your quick response.
>>>>>>
>>>>>>I have done the things you suggested. Again, it works when I create the object directly for the PRG file. When I build the COM EXE, i no longer get the error that aBlobData is undefined. However, at runtime, I get the error in the FOR loop saying "Invalid subscript reference".
>>>>>>
>>>>>>Jim
>>>>>>
>>>>>>
>>>>>Can you post code that invokes this function and also the code that checks the array size.
>>>>
>>>>Here is the code that invokes the function:
>>>>
>>>>DIMENSION aBlobData[nFileSize] AS Byte
>>>>thisform.oNPVD.GetvFBDBlob(nFileID, aBlobData)
>>>>
>>>>
>>>>Here is the code at the beginning of GetvFBDBlob:
>>>>
>>>>FUNCTION GetFBDBlob(nFileID AS Integer, aBlobData AS Byte ) AS Integer
>>>>   EXTERNAL ARRAY aBlobData
>>>>   LOCAL nResult AS Integer, nBlobSize AS Integer
>>>>   MESSAGEBOX("length of aBlobData: " + STR(ALEN(aBlobData)))
>>>>
>>>>
>>>>When I build the COM, and then run my VFP client, I get an error message saying "ABLOBDATA is not an array"
>>>>
>>>>I have tried calling with and without '@" in the call: GetvFBD(nFileID, @aBlobData) and GetvFBD(nFileID, aBlobData). Get the same error message.
>>>>
>>>>
>>>>Jim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform