List & Loop
Tag: List
The List function adds actions to a list that can be iterated in a LOOP action.
Tag Attributes
Attributes | Value Description |
---|---|
Name | Any string to ID the name |
Action | Regular action name |
Detailed Description
On top of Name and Action, LIST takes all parameters that the action to execute would take. Eg. with a LOAD action added to a LIST:
Add A LOAD server/DB action to a LIST, set Action to "Load" and add all teh LOAD regular parameters:
<List name="Doc" Action="Load" Database="AutoTest\lm_us_8.nsf" Server="ytest-MD/TESTING"/>
The LOOP processing the LIST will execute:
<Load Database="AutoTest\lm_us_8.nsf" Server="ytest-MD/TESTING"/>
Tag: Clear
The Clear function removes all content from a list.
<Clear list="Doc"/>
<!--the list is now empty-->
Tag Atttributes
Attributes | Value Description |
---|---|
List | Name of the LIST to clear |
Tag: ClearCurrentListItem
The ClearCurrentListItem removes the action currently used in the loop from the list.
<If target="Tree" test="focusRoot" mode="equals" value="false">
<ClearCurrentListItem/>
</If>
Might prove useful when two loops use the same list, and the first one needs to eliminate some entries.
Tag: Loop
The Loop function iterates over a previously set LIST of actions, executes the listed action, and executes all other actions set within the LOOP (same as a "For Each" or "ForAll" in standard programming languages).
<OnError continue="false"/><!-- general error setting breaks automation - loop OnError has priority -->
<loop list="docanal" OnError="Next"><!-- within the loop, an error will make it progress to the next action item -->
Attributes | Value Description |
---|---|
List | Name of the list to process |
OnError | Action to take in case of error within LOOP block: "ExitLoop": break loop and continue with script "Next": continue to next loop action item |
RemoveListItemUponErrorOn | Removes list action from list upon error occurring on "All": any action in the loop "ListAction": action from list |
Loop OnError has priority over the current OnError action. In this example, the script is supposed to stop when an error is raised, but this will be ignored within the loop, which will continue with the next action item from the list it's processing:
Example Text
Generic Example:
<?xml version="1.0" encoding="US-ASCII" standalone="no" ?>
<ytriaAutomation>
<!--make a list of databases to load-->
<List name="DocAnal" Action="Load" Database="AutoTest\lm_us_8.nsf" Server="ytest-MD/TESTING"/>
<List name="DocAnal" Action="Load" Database="AutoTest\lm_nab_8.nsf" Server="ytest-MD/TESTING"/>
<List name="DocAnal" Action="Load" Database="AutoTest\custinfo_s03.nsf" Server="ytest-MD/TESTING"/>
<List name="DocAnal" Action="Load" Database="websecuritystore.ntf" Server="ytest-MD/TESTING"/>
<List name="DocAnal" Action="Load" Database="YtriaLogFile-2013-03.nsf" Server="ytest-MD/TESTING"/>
<Overwrite value="false"/><!--to get exported HTML file name increment (otherwise each iteration overwrites the file)-->
<OnError continue="true"/><!-- general error setting - loop OnError has priority -->
<!--run & export doc analyzer for each database in the list-->
<loop list="docanalyzer" OnError="Next">
<ExecuteListAction/> <!-- LOAD executed here -->
<DocumentAnalyzer>
<SetParam field="TreeOptions" value="CategoryFields"/>
<SetParam field="TreeOptions" value="CategoryEncryptionNotEncryptedSecret"/>
<SetParam field="TreeOptions" value="CategorySummarized"/>
<SetParam field="DesignElements" value="true"/>
<Export>
<SetParam field="FilePath" value="D:\temp-exports\scanEZ-DocAnalyzer.html"/>
<SetParam field="ExportType" value="HTML"/>
</Export>
</DocumentAnalyzer>
</loop>
</ytriaAutomation>
The LIST is not automatically cleared after the LOOP is executed.
When OnError is not set at the loop level and set to true at script level...
<OnError continue="true"/>
<loop list="docanal""><!-- onError not set -->
</loop>
Then an error on the list action skips the entire iteration and the loop resumes to the next item in the list, as if OnError="Next" was only set for the list action.
Tag: RemoveActionFromListUponErrorOn
When List action #3 results in error (since the database does not exist) RemoveActionFromListUponErrorOn automatically removes it from the list and it's not executed in the second loop.
Example Script
<ytriaAutomation Application="scanEZ" ApplicationVersion="16.0.5.88">
<onerror continue="true"/>
<!--echo mode="false"/-->
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest5.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest1.nsf"/>
<!-- error -->
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\zer.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"/>
<loop list="MyList" RemoveListItemUponErrorOn="ListAction">
<ExecuteListAction/>
<echo value="{%LoopIndex%}/{%listSIZE%}"/>
</loop>
<echo value="---------------------------------------------------"/>
<echo value="------------------- SECOND LOOP -------------------"/>
<echo value="---------------------------------------------------"/>
<loop list="MyList">
<ExecuteListAction/>
<echo value="{%LoopIndex%}/{%listSIZE%}"/>
</loop>
</ytriaAutomation>
Tag: BreakLoop
The BreakLoop function stops current loop/while.
Example Script
<ytriaAutomation Console="true" KeepAlive="True">
<While>
<Echo value="======> while index: {%loopindex%}"/>
<if target="var" test="{%loopindex%}" mode="equals" value="3">
<breakLoop/>
</if>
<echo value="completing loop {%loopindex%}"/>
</While>
</ytriaAutomation>
Tag: ExecuteListAction
The ExecuteListAction function executes the action from the LIST at the insertion point.
<ExecuteListAction/>
You can have more than one <ExecuteListAction/> in one loop, which will do the action again.
<ExecuteListAction/> IS MANDATORY TO EXECUTE THE LIST ACTION: no <ExecuteListAction/> == the list action will simply be skipped
Example Script
<?xml version="1.0" encoding="US-ASCII" standalone="no" ?>
<ytriaAutomation>
<!--make a list of databases to load-->
<List name="LISTNAME" .../>
<List name="LISTNAME" .../>
...
<!--run & export doc analyzer for each database in the list-->
<loop list="LISTNAME">\
<SOME ACTIONS HERE/>
<EXECUTELISTACTION/><!--action from LIST-->
<SOME OTHER ACTIONS HERE/>
</loop>
</ytriaAutomation