0

Showing Value as Text

I have a tag (integer) that is 0 - 9; I want to show a text for the value itself.  Such as, '0' as OFF, '1' as ON, '2' as FAULT, etc.  Is there a formatting option for ValueBox like this?

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi sagar

    Sorry it took so long to respond to this. This one must've fallen through the cracks.

    You can you use the ValueTransform property of the ValueBox and use embedded "if" statements to accomplish this. For example,

    if(value==0,'OFF', if(value==1,'ON',...))

    Like
    • sagar
    • Designer
    • Sagar
    • 1 yr ago
    • Reported - view

    Hi, Steve Mason .  Thanks for the response.  However, it is not working.  I am using:

    if(value==0,'OFF', if(value==451,'ON'))

    I get the error below:

    04/06/2023 10:45:13 AMValueTransform failed. Control: ValueBox1, ValueTransform: 'if(value==0,'OFF', if(value==451,'ON'))', TVQ: TVQ: StartTime: 04/06/2023 10:18:12.289, EndTime: 04/06/2023 10:18:12.2890001, Value: 451, Quality: 0xC0if() takes exactly 3 arguments at NCalc.Domain.EvaluationVisitor.Visit(Function function) at NCalc.Domain.EvaluationVisitor.Evaluate(LogicalExpression expression) at NCalc.Domain.EvaluationVisitor.Visit(Function function) at NCalc.Expression.Evaluate() at AxiomCore2.ControlProperties.Value.ExecuteValueTransform(TVQ tvq)

    Like
    • sagar 

      You need a third parameter for your 2nd if statement. You have a True condition, but what if the the value does not equal 451, what should it return?

      Like
print this pagePrint this page
Like Follow
  • 1 yr agoLast active
  • 3Replies
  • 66Views
  • 3 Following