Hi
I'd like to know if someone may tell me how to convert a C string to
LabView String, because I need to use a function in C which is on a
shared library .so, that function returns a "char *parameter", and I
want to show that string to LabView through a string indicator of
LabView. I found a CIN which receives a LStrHandle and convert to CStr
string and it returns it as LStrHandle again. I modified that CIN in
order to work as I wanted, but it didn't work, LabView crashed
everytime I run this modified CIN, here is my code:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*
* CIN source file
*/
#include "extcode.h"
/* stubs for advanced CIN functions */
UseDefaultCINInit
UseDefaultCINDispose
UseDefaultCINAbort
UseDefaultCINLoad
UseDefaultCINUnload
UseDefaultCINSave
CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod);
CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod)
{
int32 len;
MgErr err = bogusError; /* bogusError is miscellaneous */
/* error code defined in extcode.h */
len = StrLen(str_orig);
/* resize modified LV string to accomodate c string */
if (err = NumericArrayResize(uB, 1L,(UHandle *)&str_mod, len))
goto out;
/* update the length of the modified LV string */
LStrLen(*str_mod) = len;
/* move len bytes from cstring to modified LV string */
MoveBlock(&str_orig, LStrBuf(*str_mod), len);
return noErr;
out:
return err;
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
So where is the error, or is there another way to do this?
I've tried to pass the output of the library function (char *) to a
LabView string indicator directly, there is no error, but the string showed in
the LabView indicator is wrong, is just garbage ... By the way I'm very
newbie in LabView :s...
Thanks in advanced
Message Edited by nmxnmx on 01-30-2006 02:32 PM
Message Edited by nmxnmx on 01-30-2006 02:34 PM