NI TestStand Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
paulmw

Expression Variables

Status: New

I was in the middle of creating an ugly expression that was parsing a string and building a file path from other standard file paths and realized that I can clean up the expressing by creating a few local variables.  But then I thought do I really want to create these local variables in my sequence that only exist for the purpose of this one expression.  Then I thought, what if I can define a variable within the expression itself, kind of how a variable is defined in C or something similar.  It only exists during the evaluation of the expression.

1 Comment
WireWeaver
Active Participant

Similar/Duplicate Post:

https://forums.ni.com/t5/NI-TestStand-Idea-Exchange/TestStand-Expression-Macros/idi-p/3326972


@Sam_Sharp wrote:

Let's say I'm building a fairly long compound expression that has some repeated parameters - I would like a way to specify (without creating additional locals) a variable/macro for use just within that expression.

 

For example, instead of:

Locals.CommandLine = "cmd /c C:\some path\that\is\reused"
Locals.CommandLine += " /path C:\some path\that\is\reused"

I could specify:

#pathmacro "C:\some path\that\is\reused"
Locals.CommandLine = "cmd /c " + pathmacro
Locals.CommandLine += " /path " + pathmacro

The idea being that with this I only need to update the macros in one place in a long expression.

 

This is a simple example, but hopefully you can see why this would be useful and why I wouldn't want to create lots of locals when the values are required only within the expression.


https://www.linkedin.com/in/trentweaver