Strings
Learn how to create and combine text values using strings in BornomalaScript.
Strings
Strings are used for text. A string can be a name, a sentence, a prompt, or any other piece of written content.
In BornomalaScript, strings are usually written inside quotation marks.
Basic Example
Create strings with quotes and join with +:
dhoro bhasa = "Bangla"
dhoro nam = "Mahfuz"
lekho("Shagotom, " + nam + "! Bhasha: " + bhasa) // output Shagotom, Mahfuz! Bhasa: Bangla
lekho("Shagotom, ${nam}! Bhasha: ${bhasa}") // same output
This example shows two important string techniques:
- Concatenation with
+ - Interpolation with
${...}
Both are common ways to build readable output.
How It Works
The first two lines create string variables:
bhasastores the textBanglanamstores the textMahfuz
The print lines then combine those values into a full sentence.
That means strings are useful whenever you want your program to work with text instead of numbers.
Concatenation
Concatenation means joining text pieces together.
Example:
dhoro prothom = "Shagotom"
dhoro ditiyo = "BornomalaScript"
lekho(prothom + " " + ditiyo)
This would print a combined message.
Concatenation is simple and works well when you want to join strings manually.
Interpolation
Interpolation lets you place variables inside a string using ${variableName}.
Example:
dhoro nam = "Mahfuz"
dhoro bhasa = "Bangla"
lekho("Shagotom, ${nam}! Bhasha: ${bhasa}")
Interpolation is often easier to read because the final sentence looks more natural.
Save and Run the File
Create a file named strings.bs, paste the example code, save it, and run:
bs run strings.bs
If the output appears correctly, you know BornomalaScript can work with text values.
Common Mistakes
Beginners often make a few simple string mistakes:
- Forgetting the quotation marks
- Mixing up single and double quotes when the syntax expects one style
- Typing variable names differently in the output line
- Forgetting spaces when building a sentence
- Using
+but leaving out a string piece by mistake
If the output looks strange, check the spaces and quotes first.
Try These Variations
Try changing the values in the example:
dhoro nam = "Amina"
dhoro bhasa = "Bangla"
lekho("Hello, ${nam}! Tumar bhasha holo ${bhasa}")
dhoro city = "Dhaka"
lekho("Ami ${city} theke eshechi")
dhoro subject = "Programming"
lekho("Amar pochondo subject: " + subject)
Changing the text helps you learn how flexible strings are.
Why Strings Matter
Strings are everywhere in software:
- usernames
- messages
- prompts
- file names
- labels and titles
Once you understand strings, you can make programs that talk to the user in a clear way.
Quick Checklist
Before moving on, make sure you can:
- Store text in a variable
- Print text with
lekho - Join strings with
+ - Use interpolation with
${...}
If yes, you are ready for numbers.