PadCodedocs

If

Runs some steps only when a condition is true, and others when it's not.

Category: Logic

#When to use it

Use it to do something only sometimes: check a form before saving, or take one of two paths.

#Example

The first step of a note's Save button:

  • Condition: isEmpty(trim(draft))
  • Then: Show Message with Text: Write something first and Style: Warning, then Stop.

The steps after the If save the note. They only run when there's something to save, because Stop ends the run otherwise.

#Good to know

  • The condition is worked out when the run reaches it, with the values as they are at that moment.
  • Empty, false, 0, empty text and an empty list count as false. Anything else counts as true.
  • If the condition can't be worked out, like a misspelled name, the step fails and the run stops. Issues points out names it doesn't know.
  • Tap the ƒ button next to Condition to write it with your variables and functions.

#Add it

Select a view, open the Inspector's Actions tab, pick when it runs, tap Add action and choose If (under Logic). Tap the step to open its settings.

#Settings

SettingWhat it doesKindDefault
ConditionA formula, like "people > 0".Condition (a formula)Required
ThenRuns when it's true.StepsRequired
ElseRuns when it's false.StepsOptional

#See also