TheWaterbug wrote:
> We have a function, GetOutputMsg(), that we export so that other apps
> (e.g. LabVIEW) can read a response from our DLL:
>
> void GetOutputMsg(char *pMsg, int nMaxBytes);
>
> LabVIEW needs to pass in a string pointer and an int so that our DLL
> knows how big a message it write to the string. Currently, we are
> using the Call Library Function module, and using a C String Pointer
> for arg1 and an int for arg2.
I do this usually by initializing an array "Initialize Array" of U8
integers of the desired size and then wiring it through the "Byte Array
to String" conversion function. Just watch out, sometimes badly
programmed C functions expect the buffer to be one char longer than the
maxBytes value indicates, for the strin
g terminating NULL char.
> How do we allocate a known amount of memory for a string in LabVIEW?
> Alternatively, if we just create a string in LabVIEW, how much space
> does it allocate, by default?
Aside from some internal space for LabVIEWs own string type it basically
allocates as many bytes for the string as there are characters in there.
This means an empty string is a pointer to an array of 0 bytes for the
underlying C function (and will certainly cause problems if the function
tries to do anything with that pointer).
Rolf Kalbermatter