Showing results for 
Search instead for 
Did you mean: 

How to determine string length when dereferencing string pointer using LabVIEW MoveBlock

Go to solution



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?

LabVIEW 2012

0 Kudos
Message 1 of 7
Accepted by topic author SteveChandler

Try this:




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.

Message 2 of 7



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



Matt J | National Instruments | CLA
Message 3 of 7

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?

LabVIEW 2012

0 Kudos
Message 4 of 7

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.

LabVIEW 2012

0 Kudos
Message 5 of 7
Accepted by topic author SteveChandler

If you configure a CLFN to call 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 ( 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.

Message 6 of 7

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.

LabVIEW 2012

0 Kudos
Message 7 of 7