Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Application Server

IF … THEN … ELSEIF … ELSE … ENDIF and attribute quality

IF … THEN … ELSEIF … ELSE … ENDIF and attribute quality

  • Last UpdatedJul 22, 2024
  • 1 minute read

When an attribute value is copied to another attribute of the same type, the attribute’s quality is also copied. This can be especially relevant when working with I/O attributes. For example, the following two statements copy both value and quality:

me.Attr2 = me.Attr1;

me.Attr2.value = me.Attr1.value;

If only the value needs to be copied and the attribute has the quality BAD, you can use a temporary variable to hold the value. For example:

Dim temp as Integer;

temp = me.Attr1;

me.Attr2 = temp;

If there is a comparison such as Attr1 <> Attr2 and one of the attributes has the quality BAD, then the statements within the IF control block are not executed. For example, assuming Attr1 has the quality BAD:

if me.Attr1<> me.Attr2 then

me.Attr2 = me.Attr1;

endif;

In this script, the statement me.Attr2 = me.Attr1 is not executed because Attr1 has the quality BAD and comparing a BAD quality value with a good quality value is not defined/not possible.

The recommended approach is to first verify the quality of Attr1, as shown in the following example:

if(IsBad(me.Attr1)) then

LogMessage("Attr1 quality is bad, its value is not copied to Attr2");

else

if me.Attr1<> me.Attr2 then

me.AttrA2 = me.Attr1;

endif;

endif;

An alternative method of verifying quality is to use the "==" operator:

if Me.Attr1 == TRUE then

Or, you can add the "value" property to the simplified IF THEN statement:

if Me.Attr1.value then

Your scripts will execute correctly if you verify the data quality using any of the above methods.

TitleResults for “How to create a CRG?”Also Available in