Skip to main content

Using Conditionals in Messages

What is 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 if the condition is true{ENDIF}
  • {IF:CONDITION} — the opening tag. Replace CONDITION with one of the conditions listed below.
  • The text between the tags — this text only appears in the message if the condition is true. It can include variables like {CRASHCAR} or {DRIVER}.
  • {ENDIF} — the closing tag. Always required at the end of every conditional block.

Important: Conditionals are processed before the message is sent, so the recipient sees only the final result — never the tags themselves.


Available Conditions

Crash and Incident Conditions

ConditionMeaning
CRASHA crash has been detected and is currently active
NOCRASHNo crash is currently active
INCIDENTAn incident has been detected and is currently active
NOINCIDENTNo incident is currently active

Flag Conditions

ConditionMeaning
FLAG=GreenThe green flag is currently showing
FLAG=YellowA yellow flag is currently showing
FLAG=RedA red flag is currently showing
FLAG=BlackA black flag is currently showing
FLAG=CheckeredThe checkered flag is out

Gap Conditions

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

ConditionMeaning
GAPHEAD<10The car directly ahead is less than 10 seconds away
GAPHEAD>10The car directly ahead is more than 10 seconds away
GAPHEAD<=10The car directly ahead is 10 seconds away or closer
GAPHEAD>=10The car directly ahead is 10 seconds away or further
GAPHEAD2<5The 2nd car ahead is less than 5 seconds away
GAPHEAD3<5The 3rd car ahead is less than 5 seconds away
GAPBEHIND<5The car directly behind is less than 5 seconds away
GAPBEHIND>5The car directly behind is more than 5 seconds away
GAPBEHIND2<5The 2nd car behind is less than 5 seconds away
GAPBEHIND3<5The 3rd car behind is less than 5 seconds away

Lap Conditions

ConditionMeaning
CARLAP>5You have completed more than 5 laps
CARLAP<10You have completed fewer than 10 laps
CARLAP=1You 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 → the message is blank and is not sent.

Example 2 — Different message depending on crash status

Use two conditional blocks back-to-back for an either/or result:

{IF:CRASH}Contact reported — 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} {IF:CRASH}— CONTACT: Car #{CRASHCAR}{ENDIF}

If crash active → Race Control Update — Car #7 Lap 12 — CONTACT: Car #42
If no crash → Race Control Update — Car #7 Lap 12


Achieving AND / OR Logic

iReporter does not have a built-in AND or OR keyword, but you can achieve the same result using the three message lines available on each button.

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}