NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Str() function: Example using "%expr"

Solved!
Go to solution

TestStand 2016 (64-bit) on Windows 10 Pro (64-bit):

 

Ran across a formatting parameter in Help describing a '%expr' format code under Str() but there is no example provided and nothing was found under Examples.

 

Anyone have one??  I've attempted several arguments/formats but none seem any more special than what one would expect of '%s'.

 

The Help text reads as:

Note: Use a format code of %expr to format an expression for display. The expression must be a localized expression. Specify combinations of the following values for parameter 3 to control how the expression is formatted:
   0x1 - Format precondition-style expressions into a simpler format.
   0x2 - Insert step name comments for expressions that use unique step Ids.
   0x4 - Use shorthand for RunState.Sequence.<StepGroup>["step"] in expression.
   0x8 - Replace unique step Ids with step names.

 

 

0 Kudos
Message 1 of 5
(3,033 Views)

Str(5.67445000, "%.2f", 1, False) Evaluates to 5.67

Str(5.67445000, "%g", 1, False) Evaluates to 5.67445

 

I'm not quite sure what you are asking here? 

 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 5
(3,002 Views)

If you review the TS help for Str(), you will see another Note about the "%b" format code (usage is same for LabVIEW).

 

I was following up on this new format code of "%expr". No example was provided.

 

P.S. Your examples are strictly inline with normal Str() use for the %f and %g format codes.

 

0 Kudos
Message 3 of 5
(2,978 Views)
Solution
Accepted by PoolMaster

So I think I understand what you are asking a little better.  Thanks for clarification. 

 

Expressions are their own unique animal in TestStand.  They are C Style syntax as well as you have access to the TestStand functions. 

 

Let's say I have a local variable of type Expression called MyExpression with a value of RunState.Sequence.Main[0].

 

If I use Str(Locals.MyExpression, "%expr", 0x4, False) the return will be {NameOfStep}. 

Whereas if you do Str(Locals.MyExpression, "%s", 1, False) the return will be RunState.Sequence.Main[0]

 

I guess it just depends on the expression and how you want it visualized.

 

 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 4 of 5
(2,976 Views)

Wow.  That's very good. I would never had thought to use an Expression-type PropertyObject directly.  I use them, of course, but never considered that specific usage.  I was also curious about the descriptions used for Parameter 3 which now make sense.

 

It's odd, one of the attempts I made was something like:

Str( Evaluate(<existing expressionObject>),"%expr") which looked just like using the %s code (as best I recall now).  So close, yet, so far.

 

Excellent, excellent.  'all hail jigg'!!!

kudos^2

 

Dave

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