08-27-2001 10:51 AM
08-27-2001 11:40 AM
Labview expects strings to sometimes be handled by using LStrHandles.
These data types are leftovers from the days when LabVIEW only ran on Macintosh.
It's unclear from your question if you are trying to create a DLL for use
inside LabVIEW or not..but I will work under the assumption you are.
Firstly, on the LabVIEW side..make sure that the string you pass to
your DLL (the allocated memory for the string) is "Adapt to Type" Type
and "Handles by Value" for the Data format. After configuring the DLL,
generate the .c code.. you will notice that your string gets passed as
"LStrHandle ErrResponse" (or whatever you named it).
In order to actually pass back your string to LabVIEW (w/o it crashing)
You must resize the passed in block of memory, tel
l LabVIEW how long the
string is, and copy the char* into it. You do this in 3 steps..
char *errBuffer; //
your internal error string
NumericArrayResize(uB,1L,(UHandle*)&ErrResponse, strlen(errBuffer));
MoveBlock(errBuffer,LStrBuf(*ErrResponse),strlen(errBuffer));
LStrlen(*ErrResponse)=strlen(errBuffer);
..and that should legally pass back your string. Make sure you pass
back the right size!
08-28-2001 07:07 AM
08-28-2001 06:34 PM