Skip to main content

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 this LAP!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.

ExampleSends 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

ConditionTrue when
(IF:CRASH)CRASHA crash is currently detected
(IF:NOCRASH)NOCRASHNo crash is currently active
(IF:INCIDENT)INCIDENTAn incident is currently detected
(IF:NOINCIDENT)NOINCIDENTNo incident is currently active

Gap Conditions

Replace the 5N with any number (seconds).of Operatorsseconds. supported:Operators: < > <= >=

ConditionTrue when
(IF:GAPHEAD<5)N or GAPHEAD1<NGap to 1st car ahead is less than 5N seconds
(IF:GAPHEAD2<5)NGap to 2nd car ahead is less than 5N seconds
(IF:GAPHEAD3<5)NGap to 3rd car ahead is less than 5N seconds
(IF:GAPBEHIND<5)N or GAPBEHIND1<NGap to 1st car behind is less than 5N seconds
(IF:GAPBEHIND2<5)NGap to 2nd car behind is less than 5N seconds
(IF:GAPBEHIND3<5)NGap to 3rd car behind is less than 5N seconds

Flag Condition

ConditionTrue when
(IF:FLAG=Yellow)YellowCurrent flag is Yellow / Caution
(IF:FLAG=Green)GreenCurrent flag is Green (racing)
(IF:FLAG=Red)RedCurrent flag is Red
(IF:FLAG=White)WhiteCurrent flag is White (final lap)
(IF:FLAG=Checkered)CheckeredCurrent flag is Checkered

Practical Examples

Notify close cars when pitting

Button

FieldContent
Message 1: 1/rc Car {CAR#}, pitting{DRIVER} Pitting this lapLAP
Button Message 2: 2(IF:GAPBEHIND1<2)/msg {CARBEHIND1} Car {CAR#} pitting this LAP!
Button Message 3: 3(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

FieldContent
Message 1: 1(IF:FLAG=Yellow)/rc Yellow flag — Car {CAR#} Lap {CARLAP} holding position
Message 2: 2(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.