NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if value in ExpressionEdit is an expression or a literal string?

Solved!
Go to solution

I am making an Edit Step dialog for a custom step type, Multiple String Value Test. The step type is set up like String Value Test only that it has a Measurement array like Multiple Numeric Limit Test. The measurement type has, among other properties, String, StringExpr, and UseStringExpr just like Limits in StringValueTest.

 

In the Edit Step dialog I use an ExpressionEdit ActiveX control to enter the string limit, either an expression that evaluates to a string or a literal string. When the text in the ExpressionEdit is an expression I want to set the value to StringExpr property on the measurement type and set UseStringExpr to True. When the text in the ExpressionEdit is a string I want to set the value to String property on the measurement type and set UseStringExpr to False, just like String Value Test does.

 

How do I differentiate between an expression and a string in an ExpressionEdit?

 

See attached images if you are unsure what I mean.

0 Kudos
Message 1 of 3
(1,093 Views)
Solution
Accepted by topic author Nesh

I think you are looking for Expression.GetConstantValue.

Message 2 of 3
(1,079 Views)

Thank you, it looks like Expression has what I need.

 

If Text is empty it is not an expression,

if Text has more than 1 token or it is not a constant value (GetConstantValue returns null) it is an expression,

else it is not an expression.

0 Kudos
Message 3 of 3
(1,065 Views)