ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Using IEnumerable<string> Variables

Banging my head on something that should be simple.  Any help is appreciated.

 

I was thinking generics were now supported in TestStand.

 

Trying to use a local variable to pass into .NET method, but getting conversion errors.  I know it is a mismatch between Array of Strings and the IEnumerable<string>, but not sure how to setup as the variable.

 

 

testergi_0-1613158443018.png

 

testergi_3-1613158550290.png

testergi_4-1613158565481.png

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 4
(1,940 Views)

Here is more details.

 

Based on link: TestStand 2010 New Features - TestStand 2019 Help - National Instruments (ni.com)

 

Generics Support

The .NET Adapter supports all fully-specified generic types that the public members of an assembly use. Thus, the adapter supports any generic type used as a parameter, return value, property, or field type in a public member. For example, you can call an assembly with a method that takes the List<Int32> type as a parameter and you can create instances of the type and call members on the type.

 

 

So the question is... how do you setup a variable to pass into method for List<string> or IEnumerable<string>?

 

 

 

0 Kudos
Message 2 of 4
(1,907 Views)

You will have to create a List<string> (the class should be available in whatever assembly uses that type in a public member) and then copy the teststand array into that using List<string>.Add() in a For Each Or For loop like the following:

 

dug9000_0-1613405047875.png

 

Unfortunately TestStand does not currently support implicit conversion of a TestStand array into a List<T> or IEnumerable<T> of the corresponding basic type. That would be a reasonable feature request though.

 

Hope this helps,

-Doug

 

Some examples of what the module specification looks like:

dug9000_0-1613405540743.png

 

dug9000_1-1613405566730.png

 

0 Kudos
Message 3 of 4
(1,895 Views)

Thanks for the info.  I finally broke down and changed my API to just use a string array to get around this.  As you mentioned, it would be nice to get this feature added as many APIs use List and flavors these days.

0 Kudos
Message 4 of 4
(1,891 Views)