Skip to main content

Using Conditionals in Messages

WhatConditional isMessages

iReporter supports conditional message lines using the (IF:condition) syntax. When placed at the very start of a Conditional?

A conditional is a way of saying "only include this part of the message if a certain situation is true." This lets a single button do different things depending on what is happening in the race at that moment — without you having to think about it.

Think of it like this: imagine you have a button labelled Contact Report. If iReporter has detected a crash, you want the message to include the car number and driver name. If there is no active crash, you want a more general message instead. Conditionals handle that automatically.


The Basic Format

A conditional block looks like this:

{IF:CONDITION}The text to show ifline, the condition is true{ENDIF}
  • {IF:CONDITION}evaluated at the moment the button is pressedtheif openingit tag.is Replacefalse, CONDITIONthat withline oneis ofsilently skipped and nothing is sent.

    Syntax

    (IF:condition)message text here

    The condition goes inside the conditionsparentheses listeddirectly below.

  • Theafter textIF:. betweenEverything after the tagsclosing ) this text only appears inis the message that will be sent if the condition is true. ItNo canclosing includetag variablesis like {CRASHCAR} or {DRIVER}.
  • {ENDIF}needed — the closingcondition tag.applies Always required atto the endwhole ofline. every

    Example

    conditional
    (IF:GAPBEHIND1<2)/msg block.
{CARBEHIND1} Car {CAR#} pitting this LAP!

Important:This Conditionalssends area processedprivate beforemessage to the messagecar immediately behind only if it is sent,within so2 seconds. If the recipientgap seesis onlygreater than 2 seconds the finalline resultis skipped neverentirely.

the tags themselves.

Available Conditions

Crash and Incident

Conditions
ConditionMeaningTrue when
CRASH(IF:CRASH)A crash has been detected and is currently activedetected NOCRASH(IF:NOCRASH)No crash is currently active INCIDENT(IF:INCIDENT)An incident has been detected and is currently activedetected NOINCIDENT(IF:NOINCIDENT)No incident is currently active

FlagGap Conditions

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

ConditionMeaningTrue when
FLAG=Green(IF:GAPHEAD<5)The green flag is currently showingFLAG=YellowA yellow flag is currently showingFLAG=RedA red flag is currently showingFLAG=BlackA black flag is currently showingFLAG=CheckeredThe checkered flag is out

Gap Conditions

These check the time gap (in seconds) to cars around you.

ConditionMeaning
GAPHEAD<10The1st car directly ahead is less than 105 seconds away
GAPHEAD>10(IF:GAPHEAD2<5)TheGap car directly ahead is more than 10 seconds awayGAPHEAD<=10The car directly ahead is 10 seconds away or closerGAPHEAD>=10The car directly ahead is 10 seconds away or furtherGAPHEAD2<5Theto 2nd car ahead is less than 5 seconds away (IF:GAPHEAD3<55)TheGap to 3rd car ahead is less than 5 seconds away (IF:GAPBEHIND<55)TheGap to 1st car directly behind is less than 5 seconds away GAPBEHIND>5(IF:GAPBEHIND2<5)TheGap car directly behind is more than 5 seconds awayGAPBEHIND2<5Theto 2nd car behind is less than 5 seconds away (IF:GAPBEHIND3<55)TheGap to 3rd car behind is less than 5 seconds away

LapFlag ConditionsCondition

ConditionMeaningTrue when
CARLAP>5(IF:FLAG=Yellow)YouCurrent haveflag completedis more than 5 lapsYellow CARLAP<10(IF:FLAG=Green)YouCurrent haveflag completedis fewer than 10 lapsGreen CARLAP=1(IF:FLAG=Red)YouCurrent 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

Button Message 1: /rc Car {CAR#} pitting this lap
Button Message 2: (IF:GAPBEHIND1<2)/msg {CARBEHIND1} Car {CAR#} pitting this LAP!
Button Message 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 on lap 1

CRASHLAP>5The crash happened after lap 5

Simple Examples

Example 1 — Show crash details only if a crash is active

You want your button to report a crash if one has been detected, or say nothing specific if not:

{IF:CRASH}Contact: Car #{CRASHCAR} ({CRASHNAME}) — {CRASHDIR}{ENDIF}

If a crash is active → message reads: Contact: Car #42 (John Smith) — ahead
If no crash is active →within the messagegap isthreshold.

blank and is not sent.

Example 2 — Different message depending on crashFlag-aware status report

UseMessage two1: conditional(IF:FLAG=Yellow)/rc blocksYellow back-to-back for an either/or result:

{IF:CRASH}Contact reportedflag — Car #{CRASHCAR} involved{ENDIF}{IF:NOCRASH}No active contact detected{ENDIF}

If crash active → Contact reported — Car #42 involved
If no crash → No active contact detected

Example 3 — Yellow flag message

{IF:FLAG=Yellow}Yellow flag showing — please slow down{ENDIF}{IF:FLAG=Green}Track is green — racing{ENDIF}

Example 4 — Close traffic warning

Alert when there is a car within 3 seconds ahead:

{IF:GAPHEAD<3}Close traffic ahead — Car #{CARAHEAD1} is only {GAPHEAD1}s in front{ENDIF}

Example 5 — Combine regular text with a conditional

You can mix normal text with conditional sections in the same message:

Race Control Update — Car #{CAR#} Lap {CARLAP} {holding position
Message 2: (IF:CRASH}—FLAG=Green)/rc CONTACT: Car #{CRASHCAR}{ENDIF}

If crash active → Race Control UpdateRacing — Car #7{CAR#} Lap 12{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 messagesCONTACT:it Caris #42
Ifshorter, noeasier crashto read, Race Control Update — Car #7 Lap 12


Achieving AND / OR Logic

iReporterand does not haverequire a built-inclosing AND or OR keyword, but you can achieve the same result using the three message lines available on each button.tag.

Simulating OR — use multiple message lines

If you want to send a message when EITHER a crash OR an incident is active, put each case on its own message line:

Line 1: {IF:CRASH}Crash: Car #{CRASHCAR} ({CRASHNAME}){ENDIF}
Line 2: {IF:INCIDENT}Incident: Car #{INCCAR} ({INCNAME}){ENDIF}

Both lines are evaluated independently. If a crash is active, line 1 sends. If an incident is active, line 2 sends. If both are active (which cannot normally happen), both send.

Simulating AND — nest your most specific condition first

If you only want a message when both conditions are true — for example, a crash AND the gap to the car ahead is very small — use the crash fallback field on the button (which only triggers when a crash is active) and add a gap condition inside it:

{IF:GAPHEAD<5}URGENT: Contact at close quarters — Car #{CRASHCAR} within {GAPHEAD1}s{ENDIF}

Because the fallback only runs when a crash is already active, this message only appears when BOTH conditions are true: crash active AND gap less than 5 seconds.


Tips for Non-Technical Users

  • Always close your blocks. Every {IF:...} must have a matching {ENDIF}. If you forget it, the message may not send correctly.
  • Spelling matters. Conditions are not case-sensitive for flag names (Yellow, YELLOW, and yellow all work), but the structure must be exact — no spaces inside the curly braces.
  • Test before race day. Use the TEST FIRE button in the settings panel to see exactly what message will be sent under current conditions. Try it with and without an active crash to confirm both paths work correctly.
  • Keep it simple. A message with one or two conditionals is much easier to read and debug than a complex chain. If you need very different messages for very different situations, consider using separate buttons.
  • Variables work inside conditionals. Any variable like {CRASHCAR}, {DRIVER}, or {GAPHEAD1} can be used inside a conditional block and will be filled in with live data when the button is pressed.

Full Working Message Examples

Race Control — Contact Report button

Message 1: /rc Race Control — {IF:CRASH}Contact: Car #{CRASHCAR} ({CRASHNAME}) Lap {CRASHLAP}{ENDIF}{IF:NOCRASH}Contact reported — no car data available{ENDIF}
Message 2: {IF:CRASH}/rc Involved car was {CRASHDIR} — please review{ENDIF}

Status Update button — works at any time

Message 1: /rc Car #{CAR#} ({DRIVER}) — Lap {CARLAP} — {IF:FLAG=Yellow}Yellow Flag{ENDIF}{IF:FLAG=Green}Green Flag{ENDIF}{IF:FLAG=Red}Red Flag{ENDIF}

Close Battle Alert

Message 1: {IF:GAPHEAD<3}CLOSE: {CARAHEAD1} is {GAPHEAD1}s ahead{ENDIF}
Message 2: {IF:GAPBEHIND<3}CLOSE: {CARBEHIND1} is {GAPBEHIND1}s behind{ENDIF}