Using Conditionals in Messages
Conditional Messages
iReporter supports conditional message lines using thea (IF:condition)simple bracket syntax. WhenPlace placeda condition in parentheses at the very start of aany message line,field — if the condition is evaluatedfalse at thepress moment the button is pressed — if it is false,time, that line is silently skipped and nothing is sent.sent for it.
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 ifonly when the condition is true. No closing tag is needed — the condition applies to the whole line.
Example
(IF:GAPBEHIND1<2)/msg {CARBEHIND1} Car {CAR#} is pitting thisLAP!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.entirely and nothing is sent.
AND and OR
Combine multiple conditions on the one line using && (AND) or || (OR). AND is evaluated before OR.
| Example | Sends when |
|---|
(CRASH && GAPBEHIND1<5)/rc Contact near traffic!A crash is active AND car 1 behind is within 5s
(CRASH || INCIDENT)/rc Incident detected!A crash OR an incident is currently active
(FLAG=Yellow && GAPHEAD<3)/rc Yellow — tight ahead!Yellow flag AND less than 3s to car ahead
You can also write AND and OR in plain English instead of && and ||.
Available Conditions
Crash and Incident
| Condition | True when |
|---|---|
| A crash is currently detected |
| No crash is currently active |
| An incident is currently detected |
| No incident is currently active |
Gap Conditions
Replace the with any number 5N(seconds).of Operatorsseconds. supported:Operators: < > <= >=
| Condition | True when |
|---|---|
or GAPHEAD1<N | Gap to 1st car ahead is less than |
| Gap to 2nd car ahead is less than |
| Gap to 3rd car ahead is less than |
or GAPBEHIND1<N | Gap to 1st car behind is less than |
| Gap to 2nd car behind is less than |
| Gap to 3rd car behind is less than |
Flag Condition
| Condition | True when |
|---|---|
| Current flag is Yellow / Caution |
| Current flag is Green (racing) |
| Current flag is Red |
| Current flag is White (final lap) |
| Current flag is Checkered |
Practical Examples
Notify close cars when pitting
| Field | Content |
|---|---|
| Message | /rc Car {CAR#}, |
(IF:GAPBEHIND1<2)/msg {CARBEHIND1} Car {CAR#} pitting this LAP!(IF:GAPBEHIND2<3)/msg {CARBEHIND2} Car {CAR#} pitting this LAP!
Message 1 always fires. Messages 2 and 3 fire only when the cars behind are within the gap threshold.threshold — each sends a separate private message.
Flag-aware status report
| Field | Content |
|---|
(IF:FLAG=Yellow)/rc Yellow flag — Car {CAR#} Lap {CARLAP} holding positionMessage
(IF:FLAG=Green)/rc Racing — Car {CAR#} Lap {CARLAP}
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.
NoteBackward on the older {{}IF{}} syntaxCompatibility
EarlierThe versions of iReporter usedolder {IF:condition}text{ENDIF}. This syntax is still fully 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.saved.