Intro to Conditional Logic
Branches are Wordsmith’s version of conditional logic. They allow you to write different text depending on specific scenarios. You’ll write conditional statements, like rules, and if those statements are true, write the text that should appear. Conditional logic can also be described as If-Then-Else.
If-Then-Else structure is common across many programming languages. While it can vary across languages, the general concept is that IF something is true, THEN do a thing. ELSE (otherwise) do a different thing. The IF statements need to evaluate to true or false. Wordsmith works the same way. You’ll write conditions (rules), these are the IF statements. If that rule is true, you’ll choose the THEN action. In the case of Wordsmith, the thing you’ll do is change what’s written in your text. Your ELSE action will be another version of your text in case the IF statement is not true. And in Wordsmith, you can have multiple IF statements within an argument, so it’s more like If-If-Then-Else.
Let’s take a look at a real example. We want to say that sales for our business rose if they are higher than they were for the previous period, fell if they were lower than the previous period, and flat if they were the same as the previous period. So we have 3 scenarios that could happen and should result in different text for each: “rose”, “fell”, or “flat”.
Following the IF-IF-THEN-ELSE syntax,
Our first rule should be:
“If sales are greater than previous sales”
This is our first IF statement
The THEN action if this rule is true will be to write the word: rose
Our next rule should be:
“If sales are less than previous sales”
This is our second IF statement.
The THEN action if this rule is true will be to write the word: fell
And otherwise if neither one of those rules are true write the word: flat
This is the ELSE action.
Our sales example is a simple one, but there are lot of interesting ways you can use conditional logic in your Branches to write specific and unique text.
Updated over 5 years ago