HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to PascalVariablesData Types & ConversionOperatorsStringsConditions (if)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
✍️ String
🔁 Condition & Loop
🧩 Function & Procedure
Pascal›Strings

Strings

Concatenation with +, Length, and UpperCase.

Simple enough for a 5-year-old to understand

Concatenation and uppercase

Example code
1
program H;
2
uses SysUtils;
3
begin
4
writeln('Hex' + 'Library');
Concatenate: HexLibrary
Output / InputConcatenate: HexLibrary
5
writeln(UpperCase('hello'));
HELLO
Output / InputHELLO
6
end.
Output / Input
💡 Hint: String concatenation is done with +. UpperCase/Length require uses SysUtils.

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (1 left)

1.Print the text 'hexlibrary' in UPPERCASE.

🎯 Expected output: HEXLIBRARY

Loading editor…

About this topic

In Pascal, strings are written between single quotes and are represented by the string type. There is a separate type for a single character; although they look similar, they are different types, and this distinction can sometimes be confusing.

String indices start at one. This is consistent with the Pascal tradition where arrays also start at one, requiring some getting used to for those coming from zero-indexed languages.

String concatenation is done with the plus operator. Explicit conversion is needed to include numbers in strings; Pascal does not convert types silently, so you need to know the conversion functions.

What you will learn

  • Creating and concatenating strings
  • Measuring length
  • Accessing characters
  • Slicing and searching operations
  • Number and string conversion

Who is this for?

  • Students working with strings
  • Developers accustomed to zero-based indexing
  • Those getting conversion errors

When to use?

Validation and formatting of user input require string operations.

String concatenation and alignment functions are frequently used in report and table outputs.

Common mistakes

Wrong

program Test;
var
  metin: string;
begin
  metin := 'hello';
  writeln(metin[0]);
end.

In Pascal, string indices start at one; the zeroth position used to hold the length information in older string types and today results in undefined behavior. To get the first character, you must use the first index.

Correct

program Test;
var
  metin: string;
begin
  metin := 'hello';
  writeln(metin[1]);
end.

Wrong

program Test;
var
  adet: Integer;
  mesaj: string;
begin
  adet := 5;
  mesaj := 'Total: ' + adet;
  writeln(mesaj);
end.

Strings and integers cannot be directly concatenated; a type mismatch error will occur. You must convert the number to a string first. Pascal never performs this conversion automatically.

Correct

program Test;
var
  adet: Integer;
  mesaj: string;
begin
  adet := 5;
  mesaj := 'Total: ' + IntToStr(adet);
  writeln(mesaj);
end.

Wrong

program Test;
begin
  writeln('O'Brien');
end.

A single quote inside a string terminates the string early and causes a syntax error. Quote escaping in Pascal is not done with a backslash, but by writing the quote twice. This is a language-specific and easily forgotten rule.

Correct

program Test;
begin
  writeln('O''Brien');
end.

Frequently asked questions

How do I measure string length?

The length function returns the number of characters. You use this value when iterating over a string in loops; since indices start at one, the loop boundary is from one to the length.

How do I convert text to a number?

There are conversion functions and they throw an error on invalid input. For user input, it is better to use the safe version that reports the result rather than throwing an error on failure.

How do I get a part of the string?

The copy function takes a starting position and length. The search function returns the position of a substring, and returns zero if not found. Together, the two handle most parsing tasks.

Summary

Strings are written with single quotes.

Text indices start at one.

Quote escaping is done by writing the quote twice.

Concatenation is done with the plus operator.

Numbers are included in strings with explicit conversion.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code