Use Read/Write I/O in Scripts
- Last UpdatedMay 22, 2024
- 1 minute read
Two common types of scripts can be written on an attribute configured with a Read/Write I/O Feature: One can look at the input side and one can look at the output side.
The input side script uses the current value coming from the input source location and performs logic or calculations on it. This script refers directly to the attribute in its expressions. For example, if the attribute is "me.attribute1", the script refers directly to "me.attribute1" for data change conditions and for expressions within the script.
The output side script can modify output or validate a new requested output value. This script refers to the "WriteValue" attribute configured on the attribute: "me.attribute1.WriteValue".
To validate a new requested value to the attribute1, for example, a data change condition expression is written on "me.attribute1.WriteValue". In addition, if the script wants to do clamping or validation, it can manipulate the "me.attribute1.WriteValue" directly to clamp the output value. For example:
If (me.attribute1.WriteValue > 100.0 ) then
Me.attribute1.WriteValue = 100.0;
Endif;
The data change expression for this script is "me.attribute1.WriteValue" because this value changes when a new value is about to be written to the field.
The script can intercept this value just before output and manipulate it. To prevent WriteValue from being written out, its data quality can be set to Bad with the SetBad() function.
For more information, see Work with Outputs.