Tag: If

The If function sets a branching condition in an XML automation script.

<IF target="Grid" test="VisibleRowsCount" mode="LessThan" value="5"> 
	<echo value="VISIBLE IN GRID < 2"/>
</IF>
XML


Tag Attributes

AttributesAttribute ValuesValue DescriptionComment
IndexN/APosition of current iteration within a loop. Allowed test values:
  • "First": true if current loop is processing the first element of the list
  • "Last": true if current loop is processing the last element of the list
  • "Other": true if current element is neither first nor last
  • "Unique": true if list has one element only. In this case, Last, First and Other are false.
  • 1, 2, ... n (any integer number)
  • Allows to check position within a loop and react accordingly. Index is exclusive and cannot be mixed with the parameters below
N/A
TargetN/A"Tree"
"Grid" (for default grid) or Grid name
"Var" for variables declared with SetVar
"List"
N/A
TestN/AWhat the IF is about:
  • "FocusRoot": tree top node
  • "SelectionCount": number of selected entries in the tree or grid set in Target
  • "VisibleRowsCount": visible rows in grid set in Target
  • Variable name, e.g. {%MyVar%} or list name
N/A
ModeN/AHow to compare:
  • "Equals"
  • "NotEquals"
  • "GreaterThan"
  • "GreaterOrEquals"
  • "LessThan"
  • "LessOrEquals"
  • "Begins"
  • "NotBegins"
  • "Ends"
  • "NotEnds"
  • "Contains"
  • "NotContains"
  • "Exists"
N/A
ValueN/A"True"
"False"
(both values only used for FocusRoot and mode for "Exists" lists)
or any integer number (SelectionCount, VisibleRowsCount)
or any text when testing variables
N/A

Detailed Description

Each of the three different If action scenarios may be combined together within the same script block if needed, as each If statement will be evaluated individually.

If actions can also be nested:

Nesting:

  • An IF can be nested within
  • Another IF
  • A LOOP
  • A modal action (action that happens within a modal dialog like Values, NotesIni etc)

With the scanEZ tree:

Example Script 

<Focus Target="Tree" Category="Profile Documents" Type="ColorProfile"/><!-- if focus tree element is not found, focus is set at tree root -- >
<If target="Tree" test="focusRoot" mode="equals" value="false"> <!-- if the tree focus is not at root level,ColorProfile was found -->
	<MySelection lastFocus="true">
		<Setparam Field="MySelectionName" Value="TheProfile1"/>
		<Setparam Field="TitleOptionType" Value="Formula"/>
		<Setparam Field="TitleOptionFormula" Value="@Implode(@DbName;"!!")"/>
	</MySelection>
</If>
XML


With a grid:

Example Script 

<!-- do some filtering on the grid -->
	<If target="Grid" test="VisibleRowsCount" mode="LessThan" value="5"> <!-- if the main grid has less than 5 visible rows -->
<!-- do things -->
	</If>

XML


Loop tests:

<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atapp.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest5.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest4.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest3.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest2.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest1.nsf"/>
	<loop list="MyList">
		<If index="last">
			<echo value="LOOP LAST"/>
		</If>
		<If index="first">
			<echo value="LOOP FIRST"/>
		</If>
		<If index="2">
			<echo value="LOOP 2"/>
		</If>
		<If index="666">
			<echo value="VADE RETRO"/>
		</If>
		<If index="4">
			<echo value="LOOP 4"/>
		</If>
	</loop>
XML


Grid & tree content tests:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ytriaAutomation Application="databaseEZ" ApplicationVersion="11.1.2.88" Version="1.0">
	<echo mode="false"/>
	<Load Server="ytest-MD/TESTING" partial="true">
		<Load Database="AutoTest\lm_us_8.nsf" Select="True"/>
		<Load Database="AutoTest\lm_nab_8.nsf" Select="True"/>
		<Load Database="AutoTest\custinfo_s03.nsf" Select="True"/>
		<Load Database="websecuritystore.ntf" Select="True"/>
		<Load Database="YtriaLogFile-2013-03.nsf" Select="True"/>
	</Load>
	<IF target="tree" test="SelectionCount" mode="GreaterThan" value="3">
		<echo value="SELECTED IN TREE > 3"/>
	</IF>
	<IF target="tree" test="SelectionCount" mode="LessThan" value="10">
		<echo value="SELECTED IN TREE < 10"/>
	</IF>
	<IF target="tree" test="SelectionCount" mode="equals" value="5">
		<echo value="SELECTED IN TREE = 5"/>
	</IF>
	<IF target="tree" test="SelectionCount" mode="equals" value="100">
		<echo value="SELECTED IN TREE = 100"/>
	</IF>
	<IF target="grid" test="VisibleRowsCount" mode="GreaterThan" value="3">
		<echo value="VISIBLE IN GRID > 3"/>
	</IF>
	<IF target="grid" test="VisibleRowsCount" mode="LessThan" value="10">
		<echo value="VISIBLE IN GRID < 10"/>
	</IF>
	<IF target="grid" test="VisibleRowsCount" mode="equals" value="5">
		<echo value="VISIBLE IN GRID = 5"/>
	</IF>
	<IF target="grid" test="VisibleRowsCount" mode="equals" value="100">
		<echo value="VISIBLE IN GRID = 100"/>
	</IF>
</ytriaAutomation>
XML


List Existential Test
By default, the LIST test checks if the list exists:
- Mode defaults to "Exists" (no other mode value shall be accepted when Target is set to "List")
- Value defaults to "True"

<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atapp.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest5.nsf"/>
	<IF target="list" test ="MyList">
		<echo value="MyList exists! Yay"/>
	</IF>
	<IF target="list" test ="MyList" value="False">
		<echo value="MyList DOES NOT exist. Booo"/>
	</IF>
	<ELSE>
		<echo value="MyList still exists! YO"/>
	</ELSE>
	<IF target="list" test ="GhostList" value="False">
		<echo value="GhostList DOES NOT exist.."/>
	</IF>
	<ELSE>
		<echo value="GhostList exists!"/>
	</ELSE>
XML