Using Conditionals in Messages
Conditional Messages
iReporter supports conditional message lines using the (IF:condition) syntax. When placed at the very start of a message line, the condition is evaluated at the moment the button is pressed — if it is false, that line is silently skipped and nothing is sent.
Syntax
(IF:condition)message text here
The condition goes inside the parentheses directly after IF:. Everything after the closing ) is the message that will be sent if the condition is true. No closing tag is needed — the condition applies to the whole line.
Example
(IF:GAPBEHIND1<2)/msg {CARBEHIND1} Car {CAR#} 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 than 2 seconds the line is skipped entirely.
Available Conditions
Crash and Incident
| Condition | True when |
|---|---|
(IF:CRASH) | A crash is currently detected |
(IF:NOCRASH) | No crash is currently active |
(IF:INCIDENT) | An incident is currently detected |
(IF:NOINCIDENT) | No incident is currently active |
Gap Conditions
Replace the 5 with any number (seconds). Operators supported: < > <= >=
| Condition | True when |
|---|---|
(IF:GAPHEAD<5) | Gap to 1st car ahead is less than 5 seconds |
(IF:GAPHEAD2<5) | Gap to 2nd car ahead is less than 5 seconds |
(IF:GAPHEAD3<5) | Gap to 3rd car ahead is less than 5 seconds |
(IF:GAPBEHIND<5) | Gap to 1st car behind is less than 5 seconds |
(IF:GAPBEHIND2<5) | Gap to 2nd car behind is less than 5 seconds |
(IF:GAPBEHIND3<5) | Gap to 3rd car behind is less than 5 seconds |
Flag Condition
| Condition | True when |
|---|---|
(IF:FLAG=Yellow) | Current flag is Yellow |
(IF:FLAG=Green) | Current flag is Green |
(IF:FLAG=Red) | Current flag is Red |
(IF:FLAG=White) | Current flag is White (final lap) |
(IF:FLAG=Checkered) | Current flag is Checkered |
Practical Examples
Notify close cars when pitting
Message 1 always fires. Messages 2 and 3 fire only when the cars behind are within the gap threshold.
Flag-aware status report
Message 1: (IF:FLAG=Yellow)/rc Yellow flag — Car {CAR#} Lap {CARLAP} holding position
Message 2: (IF:FLAG=Green)/rc Racing — Car {CAR#} Lap {CARLAP}
Note on the older {{}IF{}} syntax
Earlier versions of iReporter used {IF:condition}text{ENDIF}. This syntax is still supported for any messages you have already saved, but the new (IF:condition) form is recommended for all new messages — it is shorter, easier to read, and does not require a closing tag.