Showing posts with label operators. Show all posts
Showing posts with label operators. Show all posts

<assign name="" expr=""/>

Assigns a value to a specified variable.

The expression (expr="") can contain constants (within single quotes) or other variables (without quotes). It can also contain the addition (+), subtraction (-), multiplication (*) or division (/) operators.

Variables do not have to be explicitly declared. They are automatically declared when used.

Child of: <button>, <click>, <image>, <media>*, <media_overlay>, <mouse_click>, <mouse_down>, <mouse_move>, <mouse_out>, <mouse_over>, <node name="">, <press>, <release>, <settings>
Parent of: Nothing

* Note that an assign within a <button>, <image>, <media> or <media_overlay> tag will only be executed if the user clicks the button, image or media.

Examples:

<assign name="a" expr="'yes'"/>
after: a = yes

<assign name="a" expr="'1'+'2'"/>
after: a = 3

before: a = 3
<assign name="b" expr="'5'-a"/>
after: b = 2

before: a = 3
<assign name="b" expr="'1'+'a'"/>
after: b = 1a

before: a = 2
<assign name="b" expr="a*'7'"/>
after: b = 14

before: a = 12
<assign name="b" expr="a/'3'"/>
after: b = 4

Working example: Search for <assign name="" expr=""/> in the file trivia_demo.xml.

<if cond="">

A conditional statement used to determine what the application executes on the basis of the evaluation of one or more variables.

The value in cond="" must be an expression containing the following three elements: 1) a value, variable or function; 2) an operator; and 3) another value, variable or function.

There must be no spaces in the expression other than spaces that may be present in a text string value.

All variables used in the conditional statement must have been defined (using <assign name=""/> or <get>) before the conditional statement, either above the conditional statement in the same node, in a previous node, or in <settings> (using <assign name="" expr=""/>). If they are undefined, they will cause an error. Likewise, if an existing variable is assigned a new value using <assign name="" expr=""/>, this must be done before the conditional statement if the new value is to be evaluated.

Constants in conditional statements must be placed in single quotes; variables must not.

Allowed operators are:
== is equal to*
!= is not equal to
> is greater than
< is less than
>= is greater than or equal to
<= is less than or equal to
* Note that two equal signs are used in evaluation rather than assignment.

Child of: <node name=""> or any multi-line tag at any level within <node name="">
Parent of: Nothing

Example:

<medias>
<if cond="user_visits=='1'">
                        <media>
                                    <file>first_time_welcome.mp4</asset>
</media>
<elseif cond="user_visits=='2'"/>
                        <media>
                                    <file>second_time_welcome.mp4</asset>
</media>
<else/>
                        <media>
                                    <file>generic_welcome.mp4</asset>
</media>
</if>
</medias>

Working example: Search for <if cond="">...<elseif cond=""/>...<else/>...</if> in the file trivia_demo.xml.