Text

Your "Textual Communication"

Working with Words, Characters, and Strings

What it is

The Text category contains blocks for creating, combining, examining, modifying, converting, and formatting text.

In programming, a piece of text is commonly called a string. A string can contain letters, words, numbers, symbols, or complete messages such as:

"Clu-Bots"

What it does

The Text blocks shown in Clu-Blocks Pro allow a program to:

  • Join text.
  • Convert between characters and ASCII values.
  • Convert a value to a string.
  • Find the length of text.
  • Compare strings.
  • Extract characters or parts of a string.
  • Select a random character.
  • Encode a string.
  • Find the position of characters.
  • Join a sequence into a string.
  • Replace text.
  • Split text.
  • Remove spaces or characters from the ends of text.
  • Format text using values.
  • Process a string using the visible execution-result operation.

Example

A program could combine a label with information before sending it to the PC:

Text + Value → Serial Port → PC

Think of the Text category as the toolbox for creating and transforming the messages used by your program.

Fun Guide to Text Blocks (Clu-blocks Pro)

What it is: Blocks that allow you to work with words, phrases, and letters within your program.

What it does: It allows you to work with words, phrases, and letters.

Example: Display the message "Hello World!" on an LCD screen, combine a number with a word ("Temperature: 25°C"), or send text via Bluetooth.

It's the robot's written voice, the way it can express itself with words.

Important! Text blocks help your robot read, write, and play with words. You can join words, count letters, change characters, and even format messages. It’s like giving your robot a voice and a keyboard!

BlockWhat it doesDropdown optionsWhat the options mean
A text string—You can type any message or word here
Combines two texts—Joins words together like LEGO blocks: “HelloClu-Bots”
Turns a number into a character—65 becomes “A” great for secret codes or character tricks
Turns a character into its number—“A” becomes 65 the opposite of the block above
Converts something into text—Turns numbers, booleans, or other data into readable words
Counts how many characters are in the text—“Clu-Bots” has 8 characters (including the dash!)
Compares two textsequals, startsWith, endsWith- equals: exact match
- startsWith: begins with
- endsWith: finishes with
Gets one character at a position—Gets the first letter (position 0) “C” from “Clu-Bots”
Gets part of the text (substring)—Picks characters from position 0 to 2 like slicing a word
Picks a random character from the text—Great for games or surprises like picking a random letter
Turns text into encoded formatencode, decode- encode: turns into ASCII
- decode: turns back into readable text
 Choose encoding typeASCII, gb2312, gbk, utf-8, utf-16, utf-32Different ways to store text utf-8 is most common
Gets the middle character at position 2—Picks the third character (starts at 0) great for puzzles
Joins a list of items into one string—Turns [A, B, C] into “ABC” using “Clu-Bots” as glue
Replaces part of the text—Changes “Clu” to “Clu-block” becomes “Clu-block-Bots”
Splits text into pieces—Breaks “Clu-Bots” into parts great for analyzing words
Removes spaces from textBoth, Left, Right- Both: trims both ends
- Left: trims start
- Right: trims end
Inserts a value into a sentence—Makes “Random No. is 57” great for messages and scores
Runs a math expression inside a string—Calculates the result of the expression and returns it as text

Quick Tips for Students

  • Use join, replace, and format to build cool messages.
  • Use length, get, and split to explore and break apart words.
  • Use encode/decode for secret messages or advanced text tricks.
  • Use random and substring for games, puzzles, and creative effects.

Joining Text

[ INSERT BLOCK IMAGE HERE: Join Text ]

The first block joins two text values:

"Hello" join "Clu-Bots"

Conceptually:

Text A + Text B → Combined Text

This is useful when information needs to be assembled from several pieces.

For example:

"Temperature: " + sensor value

After converting the value to text when necessary, the complete message can be displayed or sent to the PC.


ASCII and Characters

Two blocks provide conversions between ASCII values and characters.

ASCII to Character

[ INSERT BLOCK IMAGE HERE: ASCII to Character ]

The example shows:

Ascii to Char 65

It converts the supplied ASCII value into the corresponding character.

Character to ASCII

[ INSERT BLOCK IMAGE HERE: Character to ASCII ]

The reverse operation is also available:

Char to Ascii "a"

This converts the supplied character into its corresponding ASCII value.

A useful conceptual relationship is:

ASCII value ⇄ Character


Converting a Value to Text

[ INSERT BLOCK IMAGE HERE: toString ]

The block:

toString x

converts the supplied value into a string.

This becomes important when numerical information needs to be combined with text.

For example:

Sensor Value → toString → Join Text → Serial Port → PC


Finding the Length of a String

[ INSERT BLOCK IMAGE HERE: Get Length ]

The visible example is:

get length "Clu-Bots"

This returns the length of the supplied text.

Students can think of this as asking:

How many characters does this string contain?


Comparing Text

[ INSERT BLOCK IMAGE HERE: Text Comparison ]

The category includes a string-comparison block.

The visible operator is:

equals

Conceptually:

Text A → equals → Text B

The comparison can provide a logical result that can then be used with other blocks.

For example:

Received Text → Comparison → Logic → if → Action

This is another important connection between the Text, Logic, and Control categories.


Getting a Character from a String

[ INSERT BLOCK IMAGE HERE: Get Character ]

The visible example is:

"Clu-Bots" get # 0

This block retrieves a character using the specified position.

Conceptually:

String + Position → Character

This introduces students to the idea that a string can be treated as a sequence of individual characters.


Getting Part of a String

[ INSERT BLOCK IMAGE HERE: Get Text Range ]

The image shows:

"Clu-Bots" get # 0 to # 2

Instead of obtaining only one character, this block uses two position values to obtain part of the supplied string.

Conceptually:

String → Start Position + End Position → Part of String


Selecting a Random Character

[ INSERT BLOCK IMAGE HERE: Random Character ]

The visible block is:

"Clu-Bots" Random one character

This selects one character randomly from the supplied string.

The structure is simple:

String → Random Character


Encoding a String

[ INSERT BLOCK IMAGE HERE: Encode String ]

The visible example is:

ASCII encode string "Clu-Bots"

The block contains two visible selectors:

  • ASCII
  • encode

Because both selectors are closed in the screenshot, additional choices should not be assumed in the manual.


Character and Index Operations

[ INSERT BLOCK IMAGE HERE: Character Index ]

The visible block shows:

get "Hello,Clu-Bots" MIDCharacter 1 index

This block performs the character/index operation selected in the block on the supplied string.

The visible index value is:

1

Since MIDCharacter is the only visible selection, I would preserve this terminology exactly as it appears in the current Clu-Blocks Pro interface.


Joining a Sequence into a String

[ INSERT BLOCK IMAGE HERE: Concatenate Sequence ]

The block shown is:

Using string "" to concatenate the sequence mylist into a string

This operation combines the elements of a sequence into a single string.

The first text input acts as the separator used between the elements.

Conceptually:

Sequence of Items → Join → One String


Replacing Text

[ INSERT BLOCK IMAGE HERE: Replace Text ]

The visible example is:

"Hello,Clu-Bots" Replace "Clu-Bots" as "Clu-block"

This operation contains three important pieces:

  1. The original string.
  2. The text to find.
  3. The replacement text.

Conceptually:

Original Text → Find → Replace → New Text


Splitting Text

[ INSERT BLOCK IMAGE HERE: Split Text ]

The visible example uses:

"I love Clu-Bots"

followed by:

As "" Split

This block separates a string according to the supplied separator.

Conceptually:

One String → Split → Multiple Parts

This is essentially the opposite idea of joining multiple elements into one string.


Removing Spaces or Characters

[ INSERT BLOCK IMAGE HERE: Strip Text ]

The visible block is:

"I love Clu-Bots" Strip Both Space

The two selectors shown are:

  • Both
  • Space

This block applies the selected stripping operation to the supplied string.

A simple way to introduce the visible configuration is:

String → Strip from Both sides → Space


Formatting Text with Values

[ INSERT BLOCK IMAGE HERE: Format String ]

The visible example shows:

format string "Random No. is: []" with: random int from 1 to 100

This block combines a formatted string with a supplied value.

The value in the image comes directly from a Math block that generates a random integer.

This is a particularly useful example because it demonstrates how categories work together:

Math → Text → Serial Port

A program can calculate or generate a value, place that value into a readable message, and send the result to the PC.


String Execution Result

The final visible block is:

[ INSERT BLOCK IMAGE HERE: Get String Execution Result ]

The example contains:

Get string input("1+2*3") Execution result

For this introductory manual, I would document this conservatively as the string/execution-result operation provided by Clu-Blocks Pro.

The screenshot shows the example string, but it does not provide enough information to safely describe all supported expressions or execution behavior. That can be documented later from direct testing if needed.


How Text Connects with Other Categories

Text is much more useful when combined with information produced elsewhere in the program.

Sensor information

Sensor → Value → Text → Serial Port → PC

Display information

Value → Text → LCD / OLED

User input

Serial Input → Text → Logic → Control

Creating readable messages

Sensor → Value → toString → Join / Format → Serial Port

This last pattern is especially useful for your course because instead of displaying only:

23

students can progressively learn to create a more meaningful message such as:

Temperature: 23

This helps them understand both the data and its meaning.


Quick Guide for Students

Do I need to combine two pieces of text?

Use Join Text.

Do I need to convert a value into text?

Use toString.

Do I need to know how long a string is?

Use Get Length.

Do I need to compare two strings?

Use the Text Comparison block.

Do I need one character?

Use Get #.

Do I need part of a string?

Use Get # to #.

Do I need a random character?

Use Random one character.

Do I need to replace part of a string?

Use Replace.

Do I need to separate a string into parts?

Use Split.

Do I need to remove spaces from the ends?

Look at Strip.

Do I need to create a readable message containing a changing value?

Use Format String or combine toString + Join Text.


Quick Reference

GroupMain Idea
JoinCombine text.
ASCII / CharacterConvert between ASCII values and characters.
toStringConvert a supplied value to text.
LengthObtain the length of a string.
CompareCompare text values.
Get CharacterRetrieve one character by position.
Get RangeRetrieve part of a string.
Random CharacterSelect a random character.
EncodeApply the selected string-encoding operation.
Character / IndexWork with a character position in a string.
Concatenate SequenceJoin sequence elements into one string.
ReplaceReplace specified text.
SplitSeparate text into parts.
StripRemove selected characters/spaces from the ends.
Format StringCombine formatted text with another value.
Execution ResultUse the string/execution-result operation provided by the block.