I am calling a DLL which returns a pointer to a structure consisting of a pointer to a string, a 32 bit integer, and another pointer to another string.
I have managed to use MoveBlock to return a cluster of these three things and that works fine.
But now I need to read the two strings that I have pointers to which are not fixed length. MoveBlock has a size input but how do I determine how long the strings are?
Solved! Go to Solution.
Just wire a string constant to the Input Type. If I recall correctly the terminating null (assuming C strings) will be included.
Sometimes I just MoveBlock one byte at a time until I reach a null or a specified maximum size.
You can use GetValueByPointer without needed to know the length of the string before hand. The community example for dereferencing pointers mentions that this is the perferred method for strings
Thanks. I tried GetValueByPointer but it would not work in an exe. I got an error of some kind. I think it was an error 7 file not found. I can revert the code back to when I was using that and check again when I have access.
As for reading 1 byte at a time, do I just read until I get a 0 or whatever the NULL is in C? Also would performance take a hit?
Thanks Darin. You gave two valid solutions.
The one that I am going with is reading a byte at a time until I reach the NULL. I ran into a separate problem using the xnode when running as an exe. I probably won't have time to investigate that further but it was something about file not found.
I am glad to see that all my favorite avatar's are still here answering questions! I have been really busy doing non-LabVIEW things so I have not had as much time for my favorite forum.
If you configure a CLFN to call StrLen (http://zone.ni.com/reference/en-XX/help/371361K-01/lvexcode/strlen/) you should be able to get that info. Depending on the format there are many other support functions you can call that are more well documented (http://zone.ni.com/reference/en-XX/help/371361K-01/lvexcode/support_manager_functions/) and less well documented (<LabVIEW>/cintools/extcode.h). If I'm not mistaken you should be able to call anything in extcode.h (except the macros of course) from a CLFN, just like you're using moveblock.
Awesome, thanks. I could not get this to work when I had MoveBlock configured with destination as a string. It read more than it should have and caused LabVIEW to crash. I probably had it configured wrong but what I ended up doing was to initialize a U8 array to the size returned by StrLen then use MoveBlock to fill this array, and convert the array to a string.