10-27-2008 02:13 PM - edited 10-27-2008 02:21 PM
You forgot to use count+1 in the relevant places as you did correctly in the previous example. And it would be better to use NumericArrayResize instea of DSSetHandleSize due to platform alignment differences which NumericArrayResize will take care of but DSSetHandleSize won't.
LStrHandle is equal to a pointer and that is an uInt32 for all current platforms and uInt64 for the upcoming LabVIEw for Windows 64Bit version. You could define a new type in your header like:
#if ProcessorType == kX64
#define uPtr uQ
#else
#define uPtr uL
#endif
If you have included the extcode.h from LabVIEW you should now be able to use uPtr as first parameter to NumericArrayResize() to actually allocate the right amount of memory buffer even if you ever are going to recompile that code for LabVIEW for Widows 64 Bit.
Rolf Kalbermatter
10-28-2008 07:15 AM
Hello, thank you. I modified source code and now it works, but when I pass to LabView a string via "sprintf" function, It doesn't type after the first space " " sign. Why this happens?
And also, allocating space for string -writes garbage data, I use ClearMem function to remove this stuff. Is it a correct way to do?
10-28-2008 07:24 AM
10-28-2008 08:19 AM
10-28-2008 03:49 PM
It most likely doesn't stop. But LabVIEW strings are not zero char terminated but their length is instead only determined by the len parameter inside the structure. So what is most likely happening is that LabVIEW sees a string returned like "some text\0\0\0\0\0\0\0\0\0\0\0\0\0\"
where the \0 are NUL characters. Now if you display that in a single line string control LabVIEWs automatic strong control line wrapping kicks in and since the many NUL characters are to long to fit into the line LabVIEW line breaks at the previous space character displaying the rest on the second (invisible) line. After filling in information into a LabVIEW array (and a string is really just an array too) you do have to update the len (or DimSize, which is in fact the same) to tell LabVIEW how many array elements (characters) are really there. In fact for LabVIEW arrays you shouldn't seperate the allocation of the handle and the filling in in most cases since you either allocate why to much in most cases or you will sooner or later end up filling more into a handle than you have previously allocated for it, causing those nasty crashes again.
Rolf Kalbermatter
10-30-2008 07:54 AM - edited 10-30-2008 07:58 AM
10-30-2008 12:06 PM