Text
Texts Examples of texts are:
“Thing 1”
“12. March 2010”
“” (empty text)
Text can contain letters (capital or lower case), numbers, punctuation marks, other symbols, and spaces.
Blocks
Creating text
The following block creates the text “Hello” and saves it in the variable named greeting:
The block create text with combines the value of the variable greeting and the new text “world” to create the text “Helloworld.” Please note that there is no space between the two texts, since there was none in the original texts.
To increase the number of text inputs, click the (+) symbol. To remove the last output, click the (-) symbol.
Changing text
The block to ... append adds the entered text to the given variable. In this example, it changes the value for the variable greeting from “Hello” to “Hello, there!”:
Text length
The length of block counts the number of characters (letters, numbers, etc.) contained in a text. The length of “We are #1!” is 12, and the length of the empty text is 0.
Check for empty text
This is empty block checks whether the entered text is empty (the length is 0). The result is true in the first example, and false in the second example.
Search for text
These blocks can be used to check whether a text is present in another text, and if so, where. For example, this block checks for the first occurrence of “e” in “Hello,” and the result is 2:
This one checks for the last occurrence of “e” in Hello, which is also 2:
Regardless of whether the first or last occurrence is selected, this block delivers the result 0, since “Hello” does not contain a “z.”
Extracting text
Extracting a single character
This returns “b,” the second letter in “abcde”:
This returns “d,” the next to last letter in “abcde”:
This returns “a,” the first letter in “abcde”:
This returns “e,” the last letter in “abcde”:
This contains each of the 5 letters in “abcde” with the same probability:
None of them changes the text from which these results are extracted.
Extracting a text range
The in text ... get substring from block can be used to extract a text range that either starts with:
- letter #
- letter # from end
- first letter
and ends with:
- letter #
- letter # from end
- last letter
In the following example, “abc” is extracted:
Change text capitalization
This block generates a version of the input text either written in
- UPPER CASE (all letters in caps) or
- lower case (all letters as lower case), or
- Substantive (first letters capitalized, other letters lower case).
The result of the following block is “HELLO”:
Non-alphabetic characters are not affected. Please note that this block does not work on text in languages without capital and lower case letters, like Chinese.
Trimming (removing) spaces
The following block removes spaces, depending on the settings in the drop down menu (small triangle):
- at the start of the text
- at the end of the text
- on both sides of the text
The result of the following block is “Hi you.”
Spaces in the middle of the text are not affected.
Print text
The print block causes the input value in the console window to be printed:
It is never sent to the printer, although the name might seem to indicate this.
Output text with formatting
You can use the formatted text block to output texts with formatted variable content. All place holders {} in the text are replaced with the content of the variables appended after the text. Formatting can be entered into the brackets. The formatting {:.1f}, for instance, outputs only the first decimal place in the variable t.