---
title: "if — Conditional value execution"
description: "iXML command if: Conditional value execution."
canonical_url: "https://www.zeyos.com/ixml/ref/if"
markdown_url: "https://www.zeyos.com/ai/guide/ixml/ref/if.md"
section: "ixml-reference"
authority: "reference"
language: "en"
source_repository: "https://cloud.zeyos.com/__doc/ixmldoc.xml"
source_sha256: "a23f04e6a98628ca3c273c3b8dd2c33c034cfda3e0f00478d8793074fd2f70dd"
---

# if — Conditional value execution

The IF construct is a control flow structure that allows for conditional execution of code dependent on two values.

If the condition is true, the embedded code is executed. Otherwise, a series of embedded ELSEIF and ELSEIS statements is tested one by one. Only the first ELSEIF or ELSEIS statement that is found to be true will be executed. If none of the conditions are true, the embedded ELSE statement will be executed instead.

### Attributes
| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| value1 | string |  | Value to compare from |
| value2 | string\|regexp |  | Value to compare to |
| func | string | = | Comparison function |

#### Possible values
Possible values for `func`:
- = — Equals
- =* — Equals, case-insensitive
- != — Not equals
- <> — Not equals
- !=* — Not equals, case-insensitive
- <>* — Not equals, case-insensitive
- < — Less than
- <= — Less than or equal to
- > — Greater than
- >= — Greater than or equal to
- _ — Contains
- _* — Contains, case-insensitive
- !_ — Not contains
- !_* — Not contains, case-insensitive
- ^ — Starts with
- ^* — Starts with, case-insensitive
- !^ — Not starts with
- !^* — Not starts with, case-insensitive
- $ — Ends with
- $* — Ends with, case-insensitive
- !$ — Not ends with
- !$* — Not ends with, case-insensitive
- ~ — Matches regular expression
- !~ — Not matches regular expression


### Children
- elseif (occurrence: multiple) — Elsewise conditional value execution
- elseis (occurrence: multiple) — Elsewise conditional type execution
- else (occurrence: single) — Elsewise execution

### Parents
- (not restricted in the reference)

### Result
- (none documented)

### Examples

```xml
<set var="name">iXML</set>

<if value1="$name" func="=" value2="iXML">
	<output>My name is iXML!</output>

	<else>
		<output>My name is not iXML!</output>
	</else>
</if>

<!-- My name is iXML! -->
```

```xml
<set var="name">Steve Jobs</set>

<if value1="$name" func="=" value2="Bill Gates">
	<output>My name is Bill Gates!</output>

	<elseif value1="$name" func="=" value2="Steve Jobs">
		<output>My name is Steve Jobs!</output>
	</elseif>

	<else>
		<output>My name is not Bill Gates nor Steve Jobs!</output>
	</else>
</if>

<!-- My name is Steve Jobs! -->
```

```xml
<set var="name">iXML</set>

<if value1="$name" func="~" value2="/^I/i">
	<output>My name starts with an I!</output>
</if>

<!-- My name starts with an I! -->
```
