Text

 Text

Computers work with numbers, but people communicate using words.

The Text category allows programs to create messages, combine words with data, compare information, format sensor readings, and communicate with users and other devices.

Examples:

Hello World!, Temperature: 25°C, Distance: 42 cm, Bluetooth Connected

Without Text: 23

With Text: Temperature: 23°C

Text helps transform raw data into meaningful information.


What Is Text?

A piece of text in programming is called a string.

Strings can contain:

  • Letters
  • Words
  • Numbers
  • Symbols
  • Complete sentences

Examples:

“Hello”, “Clu-Bots”, “Temperature: 25°C”, "Ready"

Think of Text as your robot’s written voice. It allows the program to communicate with people using words and messages.


Why Is Text Important?

Text appears everywhere in programming.

LCD Display - Hello World!

OLED Display - Temperature: 25°C

Serial Monitor- Distance: 42 cm

Bluetooth Message - Robot Ready

ESP-NOW Message - START


Text Category

[INSERT CATEGORY IMAGE HERE: Text]

Figure 8.1 – Blocks available in the Text category.

The Text category allows a program to:

Create text

 Combine text

 Convert values

 Compare strings

 Extract characters

 Replace text

 Split text

 Format messages

 Prepare information for displays and communication systems


Text Learning Model

CREATE

↓

COMBINE

↓

CONVERT

↓

EXAMINE

↓

MODIFY

↓

FORMAT


Text Block Quick Reference

BlockPurposeMain Idea
Text StringCreate textCreate a message
Join TextCombine textText A + Text B
ASCII → CharacterConvert number to character65 → A
Character → ASCIIConvert character to numberA → 65
toStringConvert value to text23 → "23"
LengthCount charactersHow long is this text?
CompareMatch stringsCompare text
Get CharacterExtract a characterPosition → Character
Get RangeExtract part of a stringStart → End
Random CharacterSelect random characterSurprise letter
EncodeConvert text encodingText conversion
Character IndexCharacter position operationsCharacter location
Concatenate SequenceJoin list itemsList → String
ReplaceReplace textFind → Replace
SplitBreak text apartString → Parts
StripRemove spacesClean text
Format StringCreate readable messagesValue → Sentence
Execution ResultProcess string operationEvaluate expression

Creating Text

[INSERT BLOCK IMAGE HERE: Text String]

The simplest text block creates a string.

Example:

"Hello Clu-Bots"

Conceptually:

Message

↓

Text String


Joining Text

[INSERT BLOCK IMAGE HERE: Join Text]

The Join block combines two pieces of text.

Example:

"Hello"

and

"Clu-Bots"

become:

HelloClu-Bots

Conceptually:

Text A

+

Text B

↓

Combined Text

Real Example

"Temperature: "

+

23

↓

Temperature: 23


Converting Values into Text

[INSERT BLOCK IMAGE HERE: toString]

Programs often need to combine numbers with words.

Example:

23

↓

"23"

Conceptually:

Value

↓

toString

↓

Text


Finding the Length of Text

[INSERT BLOCK IMAGE HERE: Get Length]

Example:

"Clu-Bots"

Length:

8

Students can think of this block as asking:

How many characters are in this text?


Comparing Text

[INSERT BLOCK IMAGE HERE: Text Comparison]

Programs often need to check whether messages match.

Comparison Options

OptionMeaning
equalsExact match
startsWithBegins with
endsWithEnds with

Examples:

"Clu-Bots" equals "Clu-Bots"

True

"Clu-Bots" startsWith "Clu"

 True

"Clu-Bots" endsWith "Bots"

 True


Working with Individual Characters

Example:

Clu-Bots

Positions:

0 1 2 3 4 5 6 7

C l u - B o t s


Get One Character

[INSERT BLOCK IMAGE HERE: Get Character]

Example:

"Clu-Bots"

Position:

0

Result:

C


Get Part of a String

[INSERT BLOCK IMAGE HERE: Get Range]

Example:

"Clu-Bots"

From:

0

To:

2

Returns:

Clu


Random Character

[INSERT BLOCK IMAGE HERE: Random Character]

Example:

"Clu-Bots"

may return:

C

or - o

or - s

Useful for:

  • Games
  • Password generators
  • Puzzles
  • Random word activities

ASCII and Characters

[INSERT BLOCK IMAGE HERE: ASCII to Character]

[INSERT BLOCK IMAGE HERE: Character to ASCII]

Computers store characters using numbers.

This is called ASCII.

Common ASCII Values

CharacterASCII
A65
B66
C67
a97
b98
c99
048
149
Space32

Concept:

ASCII

⇄

Character

Example:

65

↓

A


Encoding Text

[INSERT BLOCK IMAGE HERE: Encode String]

Some communication systems store text using different encoding formats.

Available Encoding Types

EncodingDescription
ASCIIStandard English text
UTF-8Most common encoding
UTF-16Extended Unicode
UTF-32Large Unicode format
GB2312Simplified Chinese
GBKExtended Chinese

 For most projects, use UTF-8.


Character Index Operations

[INSERT BLOCK IMAGE HERE: Character Index]

These blocks work with character positions inside strings.

Example:

"Hello,Clu-Bots"

↓

Position operations

↓

Character Location


Joining Lists into Text

[INSERT BLOCK IMAGE HERE: Concatenate Sequence]

Example List:

[A, B, C]

↓

Join

↓

ABC

Concept:

List

↓

Join

↓

One String


Replacing Text

[INSERT BLOCK IMAGE HERE: Replace Text]

Example:

Hello Clu-Bots

Replace:

Clu-Bots

With:

Clu-Block

Result:

Hello Clu-Block


Splitting Text

[INSERT BLOCK IMAGE HERE: Split Text]

Example:

A,B,C

↓

Split

↓

A

B

C

Concept:

One String

↓

Split

↓

Many Parts


Removing Spaces

[INSERT BLOCK IMAGE HERE: Strip Text]

Strip Options

OptionEffect
BothRemove spaces from both ends
LeftRemove spaces from the beginning
RightRemove spaces from the end

Example:

" Hello "

↓

Strip Both

↓

Hello


Formatting Messages

[INSERT BLOCK IMAGE HERE: Format String]

Formatting combines values and text.

Example:

Random Number: []

with:

57

Results in:

Random Number: 57

Other examples:

Temperature: 23°C

Distance: 42 cm

Battery: 85%

This is one of the most useful Text blocks in the entire curriculum.


String Execution Result

[INSERT BLOCK IMAGE HERE: Get String Execution Result]

This block performs the string execution-result operation available in Clu-Blocks Pro.

Example:

input("1+2*3")

At this stage students should think of it as:

Input String

↓

Process

↓

Result

Advanced uses can be explored later.


Text and Other Categories

Text becomes more powerful when combined with other categories.

Sensors

Sensor

↓

Value

↓

Text

↓

Serial

LCD

Text

↓

LCD

OLED

Text

↓

OLED

Bluetooth

Text

↓

Bluetooth

ESP-NOW

Text

↓

ESP-NOW


Most Important Beginner Pattern

Sensor

↓

Value

↓

toString

↓

Join / Format

↓

Serial Monitor

Without formatting:

23

With formatting:

Temperature: 23°C

This is one of the most important ideas students learn in programming.


Quick Guide for Students

Need to create a message?

Use:

Text String

Need to combine text?

Use:

Join

Need to convert a number into text?

Use:

toString

Need to compare words?

Use:

Compare

Need one character?

Use:

Get Character

Need to replace text?

Use:

Replace

Need a readable message?

Use:

Format String


Quick Reference

GroupMain Idea
CreateMake text
JoinCombine text
ConvertValues ↔ Text
LengthCount characters
CompareMatch text
CharacterGet one letter
RangeGet part of a word
RandomSelect random character
EncodeTransform text
ReplaceChange text
SplitBreak text apart
StripRemove spaces
FormatCreate readable messages
ExecuteProcess string expressions

Summary

In this lesson, you learned how Text blocks allow programs to create, manipulate, and communicate information using words and characters.

You explored:

 Creating strings

 Joining text

 Converting values

 Extracting characters

 Comparing text

 Replacing text

 Splitting text

 Formatting messages

 Combining Text with sensors, displays, Bluetooth, ESP-NOW, and Serial communication


Key Takeaway

Text gives your program a written voice. It transforms raw data into meaningful information that people can read, understand, and use.

By learning to create, combine, examine, modify, and format text, students develop one of the most important skills in programming: making information understandable.