# ifr statement

The ifr statement tests the result of
a logical expression.

## Syntax

```
ifr logical.exp[then|else] statement.block
ifr logical.exp then statement.block else statement.block
```

## Description

Each attribute of the first element of the expression is tested against the target. Depending on
 whether one of the attributes in the expression evaluates to either true or false, the
 statements following the then or else clauses,
 respectively, are executed.

 **mvBase**: For a program compiled in mvBase compatibility mode, the ifr
 statement differs as follows:

- The list of values to compare against is separated by a value mark rather than an attribute mark.

- The list of values is used on the right side of the equation rather than the left side of the equation.

## Example(s)

**Example 1**

```

 001 print "Input string":;input str2
 002 str1="a":@am:"b"
 003 ifr str1=str2 then print "match" else print "no match"
 run bp testifr
 Input string?a
 match
 run bp testifr
 Input string?b
 match
 run bp testifr
 Input string?ab
 no match
```

 **Example 2**

 Example ifr statement for mvBase compatibility mode:

```

 001 print "Input string":;input str2
 002 str1="a":@vm:"b"
 003 ifr str2=str1 then print "match" else print "no match"
 run bp testifr
 Input string?a
 match
 run bp testifr
 Input string?b
 match
 run bp testifr
 Input string?ab
 no match
```

## See also

- [! logical operator](https://d3codex.com/pickbasic-flashbasic/exclamation-logical-operator/)
- [$options directive](https://d3codex.com/pickbasic-flashbasic/dollar-options-directive/)
- [= assignment operator](https://d3codex.com/pickbasic-flashbasic/equals-assignment-operator/)
- [Boolean evaluation](https://d3codex.com/pickbasic-flashbasic/boolean-evaluation/)
- [if statement](https://d3codex.com/pickbasic-flashbasic/if-statement/)
- [Logical expressions](https://d3codex.com/pickbasic-flashbasic/logical-expressions/)
- [match relational operator](https://d3codex.com/pickbasic-flashbasic/match-relational-operator/)
- [not() function](https://d3codex.com/pickbasic-flashbasic/not-function/)
- [null statement](https://d3codex.com/pickbasic-flashbasic/null-statement/)
- [rewind statement](https://d3codex.com/pickbasic-flashbasic/rewind-statement/)
- [statement blocks](https://d3codex.com/pickbasic-flashbasic/statement-blocks/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [then/else statement blocks](https://d3codex.com/pickbasic-flashbasic/then-else-statement-blocks/)

---
Source: https://d3codex.com/pickbasic-flashbasic/ifr-statement/ - part of the D3Codex reference.
