NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass .NET Class Variables to a Function

Solved!
Go to solution

Currently, when I have an action/test calling a .NET function that would use a class variable, I have to add an action step before that "gets" that variable and saves it to a TestStand variable then use that TestStand variable in the subsequent function call.

 

Is there a way to directly use a .NET class variable as a parameter to a function call without modifying the .NET library so that I could avoid this 2-step process?

0 Kudos
Message 1 of 5
(2,160 Views)

Do you mean that you want to make a call into another .NET class and use the return result of that call as a parameter to a different call all in one step?

 

If so, the answer is no, you will need to store the result of the first call in an Object Reference variable at least and pass that into the second call.

 

If you meant is there a way to avoid converting the .NET type from the first call into a TestStand type and then back into a .NET type when passing it as an argument, then the answer is yes. You can store any .NET output or return value from a .NET call into a TestStand Object Reference variable. If you do that it's just stored there without any conversion to a TestStand type and you can then pass that object reference as an input to a subsequent call.

0 Kudos
Message 2 of 5
(2,095 Views)

Kind of like that except the call into a .NET class is just getting a public variable not a function call. Although I think that ends up being the same as what you described as getting that public variable is seen as a "get()" function call in TestStand. 

 

Thanks for the response.

0 Kudos
Message 3 of 5
(2,091 Views)
Solution
Accepted by topic author cjohnson963

That's correct. The TestStand expression language does not currently support accessing .NET properties on .NET objects directly.

0 Kudos
Message 4 of 5
(2,047 Views)

Ok thanks for the response. Looks like I'll have to use a custom step type to simplify things.

0 Kudos
Message 5 of 5
(2,043 Views)