Text Generators / Modifers
Generators Connected to the Source Text Parameter
Click on the Source > Text line in the Selection Overview to display all parameters
Any Generator can be connected to it by clicking on the connect button to the right of the Source Text parameter.
For example, let's connect a Random Generator:
The Source Text parameter edit box is not grayed out, but its content is completely replaced by the numerical values produced by the Generator.
The number generated is extremely accurate, which is the purpose of the Random Generator. This is the reason there a large number of digits after the decimal point.
Modifiers Applied to the Source Text Parameter
Click on the Source > Text line in the Selection overview again to ensure that the Source text parameter is displayed.
Next to the connection button, there is a button for adding Modifiers.
For example, let's add a Sub-String Generator:
Setting the End Percent parameter to 50.0 removes half of the characters from the middle of the text.
Note
Keep in mind that, chronologically, the Generator produces a result first, then a Modifier changes that result.
Implicit String Conversion to Numbers and Vice Versa
Here are two examples of the tools available from the list of Modifiers:
- Change Case: converts all or part of the characters to upper or lower case.
- Math: allows you to add or substract a number from the current value, multiply it, or divide it.
But on this page explaining Plain Text mode, we've defined that the Source Text parameter is a character string. So you might think that a string isn't a number, and that multiplying a word by two doesn't really make sense.
Why can a Modifier like Math be applied to text?
- We started by connecting a Random Numeric Generator to the Source Text.
- Then we added a Sub-String Modifier, which, as the name indicates, operates on Strings.
Two distinct types of data have been automatically converted:
- The result of the Random was implicitly converted to a String after being generated and then injected into the parameter
- The Sub-String Modifier then erases half of the characters in this String.
This Conversion can also Take Place in the Other Direction:
When Modifiers are added, Autograph analyzes the contents of the Source Text parameter to convert it into numerical data, if the text only consists of numbers.
This is the case of the previous example, when we added the Sub-String Modifier to the Random Generator.
Does this mean we can add a value of 1.0 to this number using a Math Modifier?
Yes, it works! Autograph has implicitly converted the string into numbers, added the number 1.0, and then converted the result back into a string to be injected into the Source Text parameter.
When Doesn't it Work?
If we delete the Random Generator to manually enter the word "Hello" in the Source Text parameter, the implicit conversion when adding a Math Modifier will convert "Hello" to the number 0.
So adding the value 1.0 using the Math Modifier will return the value 0 + 1 = 1.
Connecting Text to External Data
We've seen that the connection button can be used to add a Generator to the Source Text parameter. This includes Bind to Table, which lets you connect it to a table in order to set up dynamic text where content changes according to external data.
To find out more about how to connect a table to a parameter, please refer to this part of the documentation.