NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a CString array from TestStand

I have a C++ DLL that uses a CString array, CString myString[ ],  that I need to pass back to TestStand 4.0 for inclusion in my results database.
 
In the TestStand module definition the parameter argument Description comes up as a CStriing pointer (CString*) instead of a CStringArray.
 
When I put my array of strings into the Value Expression I get an error: Expected String, found Array of Strings.
 
I have no trouble passing just a string pointer but that's not working either.
 
Can someone help?
 
Thanks,
Steve S
0 Kudos
Message 1 of 6
(4,935 Views)
Hi Steve,

I don't think that you can pass a CString Array from C++ DLL to TestStand 4.0 directly.

But you can do it another way: concatenate
all Strings by a delimit in your CString Array to build a new String,  then pass it to TestStand. In TestStand you can separate those Strings by the delimit, and rebuild a String Array.

For example:
// If this is your CString Array.
CString myString[] = {"AAA", "BBB", "CCC"};

// Build a  new String in your C++, and pass it to TestStand.
char  *myNewString = "AAA~BBB~CCC";

// Separate myNewString and build an Array in TestStand...

Hope that can help you!



Message Edited by My NI on 11-29-2007 11:34 AM
Regards
MY
0 Kudos
Message 2 of 6
(4,910 Views)

Hi MY,

No problem generating and passing a single CString.

I haven't tried to generate this code yet but I'm guessing I might do the following to seperate the strings and rebuild my array in TestStand:

1. Use the Len() function to get the overall string length.

2. Use the Find() function in a loop to determine the index of the delimiting characters. Pobably hold the indexes in a local array.

3. Use the Mid() function in another loop to retrieve the desired strings and write them to the new array.

Am I on the right track or am I driving off into the weeds?

Thanks for the help

Steve S

0 Kudos
Message 3 of 6
(4,901 Views)
Hi Steve,

Why not use CStringArray in your C++ code and then specify CStringArray on the parameter type?

Regards,
0 Kudos
Message 4 of 6
(4,892 Views)
Sorry Steve, I have misunderstand your question. What I mean is the Return Value of C++ DLL, which is limited to type "Void", "Numeric", or "Boolean". You can pass Array of Strings as DLL parameter to TestStand directly.
Regards
MY
0 Kudos
Message 5 of 6
(4,885 Views)

The CStringArray class worked fine, of course.:Smiley Happy

Thanks very much to you both,

Steve S

0 Kudos
Message 6 of 6
(4,873 Views)