arc:check
Version 25.2.9314
Version 25.2.9314
arc:check
Use the arc:check keyword with or without a value parameter. Without a value parameter, it ensures that an attribute is present in an item and that it is not a null string before the body of arc:check is executed.
If you specify a value parameter, the arc:check body executes only if the expression evaluates to true. Other values are considered false. The evaluation is case-insensitive.
Like other simple conditionals in ArcScript, arc:check can be paired with an arc:else keyword.
Note: Unlike arc:equals, arc:check does not throw an exception if the attribute does not exist in the item.
Parameters
- item: The item in which to check the attribute. Specifying an item is not required. If no item is specified, the default output item is used.
- attr: The name of the attribute to check. This parameter is required.
- value: An expression that evaluates to
true
orfalse
. For example, the result of a formatter that returns true or false. - action: The action to execute if the expression evaluates to
true
. Allowed values arebreak
andcontinue
.
Control Attributes
None
Examples
Check for the presence of an attribute on an item
This example uses arc:check to check for the presence of the number
attribute on the result
item. If true, a header is added to the message. Otherwise, an error is thrown.
<arc:set attr="result.number" value="95" />
<!-- Check that the number attribute exists on the result item first. -->
<arc:check attr="result.number">
<!-- If true, add a header. -->
<arc:if exp="[result.number | lessthan(100)]">
<arc:set attr="out.header:numberlessthan100" value="true" />
<arc:set attr="out.filepath" value="[filepath]" />
<arc:push item="out" />
<!-- Else, throw an error. -->
<arc:else>
<arc:throw code="HighValue" desc="The target value was above the desired value of 100." />
</arc:else>
</arc:if>
</arc:check>
Check for a value during enumeration
This example enumerates over a range from 1 to 10 and uses arc:check to check the iteration value. If it is equal to 5, break out of the enumeration. If the value is not equal to 5, create a file with some data and push the file as output.
<arc:enum range="1..10">
<!-- Check the current iteration and break if it is equal to 5. -->
<arc:check value="[_value | equals(5)]" action="break" />
<!-- For iterations not equal to 5, create a file and push it as output. -->
<arc:setm item="out">
FileName=Result_[_value].txt
Data=The enumeration value is [_value].
</arc:setm>
<arc:push item="out" />
</arc:enum>
See Also
- arc:exists: Check if an attribute exists.
- arc:equals: Check for equality.
- arc:notequals: Check for inequality.