From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I programmatically remove comments within an expression ?

I would like to evaluate into a LabVIEW substep a TS expression. This expression may contain comment(s).
The TestStand Str() function allow to do that with the "%expr" format.
I tried to do something equivalent with the GetFormattedValue method, but the "%expr" format is not allowed.

Is there any way to do it without adding a pre-expression in my substep ?

Jean-Louis SCHRICKE
CTA - Certified TestStand Architect (2008 - 2022)
CTD - Certified TestStand Developer (2004 & 2007)
CLD - Certified LabVIEW Developer (2003 & 2005)

0 Kudos
Message 1 of 2
(2,719 Views)
There is the following API method that will help you:

PropertyObject.EvaluateEx ( exprString, evaluationOptions).

You would use this most likely on the SequenceContext. It will return a new property object with the evaluated value. For example, if exprString is "\"this is a test\" //comment here", it will be evaluated to the string "this is a test". Likewise, if you had a local variable Locals.stringVar which had a value of "abc", you could pass the expression "Locals.stringVar //comment here", and it would evaluate to "abc". It will return it in a property value (which you can call GetValNumber or GetValString, etc...), and you can then take that value and do what you please.

It sounds like you want something to evaluate to a number, then format it with a format string in LabVIEW. You can evaluate the expression to a PropertyObject that is a number type, get the value of the number, then use the Format String VI in LabVIEW.

If you are trying to do something else or I didn't answer your question, let me know.

Allen P.
NI
Message 2 of 2
(2,694 Views)