How to Inject Logic
Experiments Surveys & forms
Testable lets you add conditional branching to any trial sequence using the **`if`** and **`then`** columns. When the condition in `if` is met Testable executes the instruction in `then`; otherwise it moves to the next row.Basic structure
Section titled “Basic structure”| Column | Value |
|---|---|
if | A condition to evaluate |
then | What to do when the condition is true |
Both columns must be on the same row. If either is blank on a row, logic is not applied to that trial.
Conditions (if)
Section titled “Conditions (if)”| Condition | Matches when |
|---|---|
correct | Participant responded correctly |
incorrect | Participant responded incorrectly |
RT > 500 | Reaction time was greater than 500 ms |
RT < 300 | Reaction time was less than 300 ms |
response = cat | Participant’s response text equals cat |
responseCode = 2 | Participant selected the second option |
Negation
Section titled “Negation”Prefix a condition with ! to invert it:
if = !correctCombining conditions
Section titled “Combining conditions”Use & to require multiple conditions simultaneously:
if = correct & RT < 500Partial string match
Section titled “Partial string match”Use has() to check whether the response contains a substring:
if = response has(cat)Multiple pairs
Section titled “Multiple pairs”Separate multiple condition–action pairs with ; on the same row to evaluate them in sequence:
if = correct; RT < 300then = end; +1The first condition is paired with the first then value, the second with the second, etc.
Destinations (then)
Section titled “Destinations (then)”| Destination | Goes to |
|---|---|
30 | Trial file row 30 |
trialA | The trial labelled trialA in the label column |
+2 | Two rows forward from the current row |
-1 | One row back |
end | Skip to the end of the experiment |
screenout | Remove participant from the study (screener mismatch) |
https://example.com | Redirect participant to an external URL |
Labelling target rows
Section titled “Labelling target rows”Use the label column (an organisation column) to give a row a name, then reference it in then:
label = startBlock2...then = startBlock2This is more maintainable than hard-coding row numbers, which change when you add or remove rows.
Example: practice loop
Section titled “Example: practice loop”label = practiceStart...if = incorrectthen = practiceStartIf the participant responds incorrectly they are looped back to the start of the practice block.
Example: adaptive study
Section titled “Example: adaptive study”if = correct & RT < 400then = +3If the participant was both correct and fast, skip 3 rows to a harder condition.
Next steps
Section titled “Next steps”- Screener Surveys: use
then = screenoutto exclude participants - Using Variables: access responses in logic conditions
- Staircase Experiments: automated difficulty adaptation