Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to pass a byte array to a VFP COM server
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01504853
Message ID:
01504864
Vues:
84
>I'm developing a COM server in VFP that will provide access to a Firebird database. The server will have both VFP and C++ clients. The VFP COM server is an EXE type.
>
>One function in ths server will accept as arguments a FileID, and a reference to a byte arrary. The function will use a parameterized view to return the data of a blob field of one of the tables in the Firebird database. It will then copy these data into the byte array referenced in the calling sequence. This copy is done in a FOR loop using the SUBSTR function to copy one byte at a time from the Blob field of the view into the byte array.
>
>I've been testing this with a simple VFP client. While testing, I have been creating an instance of the server object directly from its PRG file using the NEWOBJECT function. This all works quite well. Back in the VFP client, I can see that I've gotten the data from the blob field returned in the array passed from the client.
>
>Next step is to test it creating an instance of the COM object using CREATEOBJECT.
>
>While building the COM server EXE, I get an error message saying "Unknown NBLOBDATA" - Undefined". Where NBLOBDATA is the name of the array reference in the calling sequence of the function in the VFP COM server. If I ignore this, the build continues to create the EXE and register it.
>
>When I run my test using the VFP client, I get an error message from inside the FOR loop that is copying data into the array in the function in the COM server: "Invalid subscript reference". To make sure this was actually occuring in the FOR loop when it was attempting to SUBSTR copy from the blob to the byte array, I preceded that line with a MessageBox output.
>
>I have tried preceding my call to the COM function with a call to COMARRAY(myobject, 1111). But I still get the same error.
>
>It appears to me that it does not recognize the reference I am passing to be an array.
>
>Here is the VFP PROCEDURE statement for the COM function:
>
>
>PROCEDURE GetFBDBlob(nFileID As Integer, nBlobData As Byte @)
>
>
>And, here is the code for the loop where I copy the data from the blob into the byte array:
>
>FOR i = 1 to nBlobSize
>   nBlobData[i] = SUBSTR(vFBDDataBlob.BlobData, i, 1)
>ENDFOR
>
>
>
>Thanks,
>Jim

Few changes
PROCEDURE GetFBDBlob(nFileID As Integer, nBlobData As Byte @)
should be
FUNCTION  GetFBDBlob(nFileID As Integer, nBlobData As Byte) and you should pass it by @BlobData from the caller.
and

also add
external array nBlobData as the second line in this function.

I also suggest to use aBlobData instead of nBlobData as a usually an indication of array in VFP.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform