Tag: SetVar

The SetVar automates the action of setting a value to a variable or, in the case of a few "reserved" values, call specific value types on demand. Multiple variables can be set within the same script line.

<SetVar Expres1="Help" Expres2="Page"/>
<echo value="{%Expres1%}, {%Expres2%} {%date%}"/>

Tag Attributes

AttributesAttributes ValuesValue DescriptionComment
Variable NameN/A

Any unreserved name valid in XML. Reserved names are:

Date: current date MM/DD/YYYY
Loop context

LoopIndex: Current loop index
ListSize: Current list size
ListName: Current list name
FolderDocuments: Windows account Documents folder path (%USERPROFILE%\Documents)
FolderTemp: Ytria temp folder path (%LOCALAPPDATA%/Ytria)

Variable ValueN/AAny string or numberN/A

Detailed Description

The variable can be referenced to in the script after its declaration with SetVar. To reference a variable, enclose it in: {% and: %}.
Variable names are not case sensitive. Referencing a variable that was not previously declared with SetVar does nothing (the string is not replaced).

Example Script

<!-- declare variables chaise & singe-->
<SetVar chaise="viande" singe="oui"/>
<!-- use variables chaise & singe-->
<echo value="{%chaise%}, {%singe%} {%singe%}? {%date%}"/>

Variables can use other variables:

<SetVar mugre="zer"/>
<SetVar camion="{%mugre%}"/>
<echo value="{%camion%} (mugre) {%mugre%}"/>

Loop context:

<ytriaAutomation Application="scanEZ">
	<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"/>
	<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\mugre.nsf"/><!-- does not exist -->
	<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"/>
	<SetVar mugre="zer" ningen="isu" justin="miasma"/>
	<SetVar chaise="viande" singe="oui"/>
	<SetVar today="{%date%}"/>
	<SetVar now="{%time%}"/>
	<SetVar camion="{%mugre%}"/>
	<loop list="MyList">
		<echo value="{%ningen%} {%mugre%}, {%singe%}? {%today%}"/>
		<echo value="{%mugre%} and {%mugre%} again, now is {%now%} and {%time%}"/>
		<echo value="{%justin%} is not {%chaise%} {%doesnotexist%} at {%LiStNamE%}: {%loopindex%}/{%listSIZE%}"/>
		<echo value="{%camion%} (mugre) {%mugre%}"/>

Variable test with IF:

- Target: "Var"
- Test: "{%MyVar%}"
- Mode: any valid operation
- Value: anything, including another variable or combination of variables with other text

<IF target="var" test="{%chaise%}" mode="notequals" value="{%camion%}">
	<echo value="chaise is {%chaise%}, not {%camion%}"/>

If both the variable value (test=) and the testes value (value=) are numbers (integer or floating), the comparison is computed with the corresponding numbers. If one of these two values is not a number, the test is performed lexicographically:

<loop list="MyList">
	<IF target="var" test="{%loopindex%}" mode="LessThan" value="3">
		<echo value="{%loopindex%} < 3 in {%listName%}"/>

New test modes:

<SetVar MyVar="sapio365"/>
<if target="Var" Test="{%MyVar%}" mode="contains" value="pio">
	<echo value="{%MyVar%} contains pio"/>
<if target="Var" Test="{%MyVar%}" mode="notcontains" value="666">
	<echo value="{%MyVar%} does not contains 666"/>
<if target="Var" Test="{%MyVar%}" mode="Begins" value="sap">
	<echo value="{%MyVar%} begins with sap"/>
<if target="Var" Test="{%MyVar%}" mode="notBegins" value="mugre">
	<echo value="{%MyVar%} does not begins with mugre"/>
<if target="Var" Test="{%MyVar%}" mode="ends" value="io365">
	<echo value="{%MyVar%} ends with io365"/>
<if target="Var" Test="{%MyVar%}" mode="notBegins" value="gorgonzola">
	<echo value="{%MyVar%} does not begins with gorgonzola"/>