08-21-2006 09:44 AM
08-21-2006 01:54 PM
Because the way Labview handles strings is so different than the way C handles strings, it would be very difficult to do this with your particular array without using a wrapper. If it were simple strings or a 1D array of char, this is how it could be done, as long as all the strings are the same length. Sorry, I can't include a picture or some code because I am not at my work computer, so I will try to explain.
Convert each char array to a byte array. You would then have an array of byte arrays. This big array must be converted into a cluster. Right click on the Array to Cluster function and set the length of the cluster to the length of the byte array. There is a limit on how big it can be, forgot what it was. Do the same for the second string array. Then bundle all into a bigger cluster. Pass the bigger cluster (cluster of clusters of arrays of byte arrays) into the Call Library Node, set parameter to Adapt to Type, and data format to Pointers to Handles.
Now for your problem. You have a 2D array of char. In order to get by with this, you would have to list each row separately as 1D arrays. Convert each one into clusters, and then bundle all into a cluster. So your final cluster would have 5 clusters of byte arrays of Name_Len elements and 5 clusters of byte arrays of Value_Len elements. Whew! Try it if you dare, or just write a wrapper.
08-21-2006 02:56 PM - edited 08-21-2006 02:56 PM
Message Edited by gborges on 08-21-2006 02:58 PM
08-22-2006 07:14 AM - edited 08-22-2006 07:14 AM
Message Edited by gborges on 08-22-2006 07:21 AM
08-22-2006 10:41 AM - edited 08-22-2006 10:41 AM
A picture is worth more than 1000 words:
Message Edited by tbob on 08-22-2006 09:42 AM
02-04-2011 09:53 AM
This seems to be very close to what I need, but it doesn't quite work.
I have to interface to a DLL which has the following parameter list:
DLLEXPORT int test_string_array(unsigned int argc, const char *argv[], char *str_ret);
And the char *argv[] is causing me a lot of problems.
I tried the method mentioned here, as well as a 2-d byte array, using various ways of combining them (build array, build cluster, bundle, etc).
Nothing I tried seemed to work.
I guess char *argv[] is an array of pointers to chars. So is there a way to get labview to interface to this datatype?
It would be a huge help if someone could provide any info on this at all!
09-17-2013 12:31 PM
I have the same problem. Great if someone can come up with a solution 🙂
09-18-2013 02:34 AM - edited 09-18-2013 02:37 AM
If you really want to do an array of string pointers, contrary to an array of fixed size arrays, then you will either have to write a wrapper in C or get your brain cells cooked in trying to come up with a solution that generates the necessary array on the LabVIEW diagram using numerous calls to the LabVIEW memory manager functions DSNewPtr(), MoveBlock() and DSDisposePtr() in a loop. This will created code that is:
- painful to maintain for future releases of your application including moving to different platform
- not possible to move between 32 bit and 64 bit of LabVIEW without two different diagram sections for each version
- a bitch to debug until you get it not to crash
- even if you do not crash you are very likely to still corrupt some memory somehow because you got the offsets and lengths somewhere wrong. This not crashing bugs are the most fun, since they corrupt somewhere memory that will eventually crash your program anyhow, but sometimes only hours or days after the corruption happened.
Basically writing such a solution in the LabVIEW diagram will require you to know a lot more about C compilers and how they are aligning and setting up pointers and such stuff in memory than if you wrote the wrapper DLL. So those not able to create a DLL in C are lost anyhow and those who know how to do it in C will surely go for the wrapper solutions, since that is much easier to maintain in the long run.
09-18-2013 01:14 PM
Here's one way you can do it in LabVIEW, although as Rolf explained it does require the use of several LabVIEW memory manager calls:
http://lavag.org/topic/14642-passing-array-of-string-to-c-dll/#entry87758