# Using Conditional Statements in Messages

## Conditional Messages

iReporter supports conditional message lines using a simple bracket syntax. Place a condition in parentheses at the start of any message field — if the condition is false at press time, that line is silently skipped and nothing is sent for it.

## Syntax

```
(condition)message text here
```

Everything after the closing `)` is sent only when the condition is true. No closing tag needed — the condition applies to the whole line.

### Example

```
(GAPBEHIND1<2)/msg {CARBEHIND1} Car {CAR#} is pitting this lap!
```

This sends a private message to the car immediately behind only if it is within 2 seconds. If the gap is greater the line is skipped entirely and nothing is sent.

## AND and OR

Combine multiple conditions on the one line using `&&` (AND) or `||` (OR). AND is evaluated before OR.

<table id="bkmrk-examplesends-when-%28c"><thead><tr><th>Example</th><th>Sends when</th></tr></thead><tbody><tr><td>`(CRASH && GAPBEHIND1<5)/rc Contact near traffic!`</td><td>A crash is active AND car 1 behind is within 5s</td></tr><tr><td>`(CRASH || INCIDENT)/rc Incident detected!`</td><td>A crash OR an incident is currently active</td></tr><tr><td>`(FLAG=Yellow && GAPHEAD<3)/rc Yellow — tight ahead!`</td><td>Yellow flag AND less than 3s to car ahead</td></tr></tbody></table>

You can also write `AND` and `OR` in plain English instead of `&&` and `||`.

## Available Conditions

### Crash and Incident

<table id="bkmrk-conditiontrue-when-c"><thead><tr><th>Condition</th><th>True when</th></tr></thead><tbody><tr><td>`CRASH`</td><td>A crash is currently detected</td></tr><tr><td>`NOCRASH`</td><td>No crash is currently active</td></tr><tr><td>`INCIDENT`</td><td>An incident is currently detected</td></tr><tr><td>`NOINCIDENT`</td><td>No incident is currently active</td></tr></tbody></table>

### Gap Conditions

Replace `N` with any number of seconds. Operators: `<` `>` `<=` `>=`

<table id="bkmrk-conditiontrue-when-g"><thead><tr><th>Condition</th><th>True when</th></tr></thead><tbody><tr><td>`GAPHEAD<N` or `GAPHEAD1<N`</td><td>Gap to 1st car ahead is less than N seconds</td></tr><tr><td>`GAPHEAD2<N`</td><td>Gap to 2nd car ahead is less than N seconds</td></tr><tr><td>`GAPHEAD3<N`</td><td>Gap to 3rd car ahead is less than N seconds</td></tr><tr><td>`GAPBEHIND<N` or `GAPBEHIND1<N`</td><td>Gap to 1st car behind is less than N seconds</td></tr><tr><td>`GAPBEHIND2<N`</td><td>Gap to 2nd car behind is less than N seconds</td></tr><tr><td>`GAPBEHIND3<N`</td><td>Gap to 3rd car behind is less than N seconds</td></tr></tbody></table>

### Flag Condition

<table id="bkmrk-conditiontrue-when-f"><thead><tr><th>Condition</th><th>True when</th></tr></thead><tbody><tr><td>`FLAG=Yellow`</td><td>Current flag is Yellow / Caution</td></tr><tr><td>`FLAG=Green`</td><td>Current flag is Green (racing)</td></tr><tr><td>`FLAG=Red`</td><td>Current flag is Red</td></tr><tr><td>`FLAG=White`</td><td>Current flag is White (final lap)</td></tr><tr><td>`FLAG=Checkered`</td><td>Current flag is Checkered</td></tr></tbody></table>

## Practical Examples

### Notify close cars when pitting

<table id="bkmrk-fieldcontent-message"><thead><tr><th>Field</th><th>Content</th></tr></thead><tbody><tr><td>Message 1</td><td>`/rc Car {CAR#}, {DRIVER} Pitting this LAP`</td></tr><tr><td>Message 2</td><td>`(GAPBEHIND1<2)/msg {CARBEHIND1} Car {CAR#} pitting this LAP!`</td></tr><tr><td>Message 3</td><td>`(GAPBEHIND2<3)/msg {CARBEHIND2} Car {CAR#} pitting this LAP!`</td></tr></tbody></table>

Message 1 always fires. Messages 2 and 3 fire only when the cars behind are within the gap threshold — each sends a separate private message.

### Flag-aware status

<table id="bkmrk-fieldcontent-message-1"><thead><tr><th>Field</th><th>Content</th></tr></thead><tbody><tr><td>Message 1</td><td>`(FLAG=Yellow)/rc Yellow flag — Car {CAR#} Lap {CARLAP} holding position`</td></tr><tr><td>Message 2</td><td>`(FLAG=Green)/rc Racing — Car {CAR#} Lap {CARLAP}`</td></tr></tbody></table>

### Combined condition

```
(CRASH && GAPBEHIND1<5)/rc Contact AND close traffic behind — Car {CARBEHIND1} at risk
```

## Using the Variable Picker

Type `(` in any message box to open the variable picker and browse all available conditions. AND / OR examples are included at the bottom of the list.

## Backward Compatibility

The older `{IF:condition}text{ENDIF}` syntax is still fully supported for any messages you have already saved.