Introducing... Pack Grammar!!!!
Pack grammar is here and ready to go! Automio can now distinguish whether an item is the first or last entered into the Pack.
Before we get stuck in on how to use Pack Grammar make sure you are confident using Packs. If you are still a bit unsure and would like some guidance check out these articles first:
• What is a Pack?
• How to create a Pack
• How to use Pack References
Why do I need Pack Grammar?
Before Pack Grammar was introduced there was no way to treat First, Last, and Middle items differently, which means that certain grammar structures, like including "and" for the last item, was not supported. This is no longer an issue! You now have the ability to list names from a pack, and include "and" before the last name. E.g Mary, John, Jane and Susan.
For the purpose of this article I am making a shopping list and I am using a Pack to list what fruit I would like to buy.
This is what the finished product looks like on the editor tool:
The finished output looks like this:
Notice each fruit has a comma after it and an "and" before the last one? That's Pack Grammar.
So how do I use Pack Grammar?
I've started to make my grocery list and I've created a Pack and Pack Reference the same as I normally would (if you are unsure how to create a Pack or Pack Reference check out the above articles). My flow now looks like this:
On the "repeat for each" branch I can now start adding the grammar.
The first step is to ask whether the item is first.
1. Create a question point with two branches. You can name it whatever you want I am going to name mine "Is this item first?".
2. Select the drop down menu "Use a default value from another question". Under "This Reference" There are three preset questions that relate to Pack Grammar these are 'First', 'Last' and 'Single'.
3. Select the value "First". This will ask Automio whether the item is first.
4. Label the top branch 'Yes' with a value of 'yes' and the bottom branch 'No' with the value as 'no'.
Your flow will now look something like this:
We will complete the 'yes' it is first branch first.
1. On the 'Yes' branch add a text snippet with the text you would like for your output. In this example I am only putting the fruit token. Make sure you don't put any spaces before or after.
2. Create a question point with two branches similar to the one created above. You can name it whatever you want I am going to name mine "Is this item last?".
3. Select the drop down menu "Use a default value from another question". Under "This Reference" There are three preset questions that relate to Pack Grammar these are 'First', 'Last' and 'Single'.
4. Select the value "Last". This will ask Automio whether the item is last.
5. Label the top branch 'Yes' with a value of 'yes' and the bottom branch 'No' with the value as 'no'.
6. After the Yes branch for this question I am going to add a text snippet with nothing but a full stop in it.
7. After the No branch I am going to add a text snippet containing a comma with a space afterwards ", "
The first "no" it isn't first branch
1. Add another question asking whether the item is last (Follow steps 2 - 5 above) on the first 'No' branch shown below:
2. On the newly created Yes branch add a text snippet containing and with a space afterwards "and[space]".
3. Then add a jump point to the text snippet containing the fruit text.
4. Add a jump point after the No branch to the same text snippet containing the fruit text.
Each item will go down the repeat for each branch and be asked whether the item is first, if yes the text will appear. Next it will be asked whether this item is last, if it is (the only item) a full stop will appear if not, a comma will appear after the item instead.
If the item is not the first entered it will go down the first no branch, it will then be asked whether this is the last item. If it is last 'and' will appear in front of it and then it will jump to create the text output and a full stop. If it isn't first and it isn't last it will jump to the fruit text and have a comma after it.
Pack grammar can be hard to wrap your head around.
I have tried my best to explain it in this article but if you have any questions contact one of our team.