CondRead syntax

I can't get the syntax correct and The examples i'm seeing don't exactly help.

This is for a contextual display of course.

DLSYS.CondRead(Dsp.Tag+'/HHILK_LIM.CV',"")

I'm trying to read HHILK_LIM which may or may not exist. Return blank string if it doesn't.

Thanks

  • The return if not exist value is "********". But I don't have an error in Diagnostics. The script assistant is saying..
    "The expression should be in the form of...."

    If the value does exist.. it shows the correct value. Can I ignore the comments on the script assistant.. and what is wrong with the return value if not exist. Maybe the quotations?
  • In the first statement you are using single quote but second is using double...it shouldn't matter but try changing the second one to double single quote.

    it may also be that you are reading a number and returning a string if bad so depending on where this CondRead result is going it may have issues with writing a string to a number without extra formatting.

  • In reply to Matt Stoner:

    I'm slightly confused by your comments about single, double and double single quotes.. ;)

    It's just being displayed on the CD.. not being used in any other way so i should be fine with the different datatypes. But, yes, I am reading a number.

    I actually modified an existing GEM and the data source is this parameter.. and it's a Scaled Numeric type.. So, I guess you are on to something there. The bad return is a string that then is being used by the data source expecting a scaled numeric. I think i will just do this outside of a GEM and see where I get.
  • In reply to Matt Stoner:

    yes, that seems to be the issue. The data source being numeric and trying to return a string. It works fine to read the parameter which is a floating point as a data link string type. Then when I return the string if doesn't exist. it's happy still.
  • In reply to TreyB:

    In the conditional read path it is using 'path' (single quotes) and the fall back has "" (double quotes). They both should work but I suspected it was more an issue of data types being used. You could return 'undefined' instead of '' if you don't want it to be happy. Not sure what you are looking to do if it doesn't exist.
  • In reply to Matt Stoner:

    Yeah, i guess I wasn't sure what the fall back value wanted. All the examples in BOL show an alternate path, i believe. But, I didn't want to create some NULL parameter. I just wanted to return a specific "value".. in this particular case, just blank. In some cases 'undefined' would be suitable. I used the double quotes expecting that it would treat that as returning a string value. But, as we discovered (perhaps).. returning that to a datalink expression that is set as a 'numeric' type doesn't work well. Thanks
  • In reply to TreyB:

    Returning a String into a Number would create a conflict as numbers are much more restricted in terms of what is valid. There is no "NULL" number.

    However, if the parameter does not exist, how does the expression know it should be receiving a number? Is this an animation on a Number variable? Seems to me that if this is a Display Expression, the non-existent path could be any parameter type. Can you share the context of your expression?

    Andre Dicaire

  • In reply to Andre Dicaire:

    So, this was an interlock limit parameter on a contextual display (detail). It was using the Emerson OOB display to begin. I copied the CD_LABEL_SCALEDVALUE Gem used for the alarm limits and tried to change just the parameter. Gem.Parameter is a Parameter Reference property in the configuration pane. This is then referenced by the datalink expression. So, the actual datalink has Data Source/Expression as Gem.Parameter. It is of type Scaled Numeric. So, that is perhaps the issue with returning a "string". I'm not sure how I would go about making the CondRead expression work to have my "fallback" value be a numeric value.

    Let's say i did DLSYS.CondRead('path', NUM).

    So, i have a parameter reference for 'path', and then I don't know how I would write NUM if i wanted just a static value. So, would it be: '0' or maybe no quotes at all and just do:

    DLSYS,CondRead('path', 0 )

    I think I tried just leaving the second part of the function call blank
    DLSYS.CondRead('path', )

    but that didn't work.
  • In reply to TreyB:

    The idea here is that you have some logic based on a parameter that may or may not exist. Maybe an animation or a value you display. If the parameter does not exist, you can set a benign value that will allow your logic to respond as needed.

    If you were expecting to hide the value by showing Nothing, you could still set a value and then set a visibility animation to hide the value. i.e. set value to 0.0 and then set animation to hide if <= 0. But if 0 is a possibly valid value that you would want to show, hmm.

    How about a conditional read on the .ST and set this default to an invalid status value that could never be returned if the parameter exists? Use this condRead in the visibility animation.

    My take is to keep it simple, and if using 0 as the default works, do that.

    Andre Dicaire