NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create a function using TestStand variables and call it from a step's Pre-Expression?

Solved!
Go to solution

In one sequence I have dozens of Pre-Expressions which are almost the same thing, like this...

 

Locals.tagID = (Parameters.singlePhaseEnabled ? "L" : "D") & Str(Locals.phase) & "006"

 

...and the only thing different is that three digit string at the end ("006" will vary). How can I write a function that I can call from a step's Pre-Expression so it would look something like this? ...

 

Locals.tagID = MyNewFunction("006")

0 Kudos
Message 1 of 3
(4,847 Views)
Solution
Accepted by topic author bmihura

You cannot write custom commands for expressions.

That being said, there are a couple of options:

  • Create a subsequence with a single step. Use a parameter of the sequence as "function parameter".
  • Create a custom step type including a substep module which implements the function. Add an edit substep to enable the user of the steptype to gracefully change the parameter.
  • Store the variable parameter in a local/file global variable and modify the value in each step. This will, at least, keep the "function" the same for every step.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 3
(4,791 Views)

Good ideas, thanks.

 

Bruce

 

0 Kudos
Message 3 of 3
(4,760 Views)