Main Topic

Laurent SEITER/YTRIA
06/22/2022 03:42 PM




Subject:

List & Loop

Category:

  

V 16.0.5.77

LIST
adds actions to a list that can be iterated in a LOOP action

Attributes
Nameany string to ID the list
Actionregular action name
:
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="DocAnal" 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"/>


CLEAR
Removes all content from a list

Attributes
Listname of the LIST to clear

<Clear list="DocAnal"/>
<!--the list is now empty-->


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.


LOOP
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)

Attributes
Listname of the LIST to process
OnErroraction to take in case of error within LOOP block:
"ExitLoop": break loop and continue with script
"Next": continue to next loop action item
RemoveListItemUponErrorOnremoves 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 it is asked to continue with the next action item from the list it is processing:

<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 -->

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="docanal" 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>

NB:
- the list action is executed at the beginning of the loop, except if an EXECUTELISTACTION action is found (see below)
- 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 set only for the list action.


RemoveActionFromListUponErrorOn example:
List action #3 results in error since the database does not exist.
It is automatically removed from the list and is not executed in the second loop:

<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>


BREAKLOOP

Stops current loop/while.

<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>



EXECUTELISTACTION
Executes the action from the LIST at the insertion point instead of the beginning of the loop.
Note: you can have more than one <ExecuteListAction/> in one loop, which will do the action again

NB: <ExecuteListAction/> IS MANDATORY TO EXECUTE THE LIST ACTION: no <ExecuteListAction/> == the list action will simply be skipped

<?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>