HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to ClipperVariablesStringsConditions (IF / DO CASE)Loops (FOR / DO WHILE)DBF Database
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
✍️ Text & Number
🔁 Condition & Loop
🗃️ Functions & Database
Clipper›Strings

Strings

String concatenation, length, and commonly used string functions.

Simple enough for a 5-year-old to understand

String concatenation

Example code
1
LOCAL name := "Alex"
2
QOut("Hello " + name)
Concatenates with a plus.
Output / InputConcatenates with a plus.
Output / Input
💡 Hint: String concatenation in Clipper is done with the plus sign.

🎯 Exercise & Practice

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

1.Which operator combines two strings?

About this topic

In Clipper, strings can be enclosed in double quotes, single quotes, or square brackets. All three forms are equivalent; this flexibility makes it possible to include quotes inside a string without needing an escape character.

There are two operators for string concatenation. The plus operator appends the parts as they are. The minus operator takes the trailing spaces of the left-hand part and moves them to the end of the result; it prevents space accumulation when concatenating fixed-width fields and is unique to the xBase family.

The most important detail is comparison. In Clipper, string comparison using a single equals sign only checks for a match from the beginning when a setting is turned off: a short string is considered equal to a long string that starts with it. If you want exact equality, you must use a double equals sign.

What you will learn

  • String delimiters
  • The two concatenation operators
  • For length and substring extraction
  • Space trimming functions
  • Exact equality comparison

Who is this for?

  • Those who generate report and invoice outputs
  • Those surprised by the comparison result
  • Those working with fixed-width fields

When to use?

When fixed-width text fields in a data file are read, the right side comes filled with spaces; trimming functions should be used before comparison and concatenation.

Left and right padding functions are used to align report lines; this is the standard method in documents printed with a fixed-width font.

Common mistakes

Wrong

PROCEDURE Main()
   LOCAL ad := "Ahmet"
   IF ad = "A"
      ? "matched"
   ENDIF
   RETURN

A comparison with a single equals sign only looks at the characters on the left when the exact match setting is off; a single-letter string is equal to any string starting with it, and the condition evaluates to true. A double equals sign should be used for exact equality. This behavior is the source of countless hidden bugs in legacy code.

Correct

PROCEDURE Main()
   LOCAL ad := "Ahmet"
   IF ad == "A"
      ? "matched"
   ENDIF
   RETURN

Wrong

PROCEDURE Main()
   LOCAL ad := "Ahmet     "
   LOCAL soyad := "Yilmaz"
   ? ad + " " + soyad
   RETURN

Because the trailing spaces of the field are carried over as they are, a long gap is created between the first name and the last name. This is standard behavior for fixed-width fields read from a data file. It is necessary to use a trimming function or choose the minus operator, which moves the spaces to the end.

Correct

PROCEDURE Main()
   LOCAL ad := "Ahmet     "
   LOCAL soyad := "Yilmaz"
   ? AllTrim(ad) + " " + soyad
   RETURN

Wrong

PROCEDURE Main()
   LOCAL metin := "merhaba"
   ? SubStr(metin, 0, 3)
   RETURN

In the substring function, positions start at one; zero is not a valid starting position and the function will return unexpected results. To get the first characters, you must start from position one or use the take-from-beginning function.

Correct

PROCEDURE Main()
   LOCAL metin := "merhaba"
   ? SubStr(metin, 1, 3)
   RETURN

Frequently asked questions

What is the exact match setting?

It is a program setting that determines whether string comparisons made with a single equals sign match exactly or just from the beginning. It is off by default. If you do not want the behavior to depend on the setting, always use a double equals sign.

What is the difference between the two concatenation operators?

The plus operator appends the parts as they are. The minus operator cuts the trailing spaces of the left-hand part, appends them to the result, and moves those spaces to the very end of the combined string; thus, the total length is preserved. It is useful in fixed-width report lines.

How do I convert text to a number?

There are conversion functions; if a string cannot be converted to a number, it returns zero without throwing an error. Because of this silent behavior, a numerical test on user input must be performed separately.

Summary

Strings can be written with three different delimiters.

The minus operator moves spaces to the end.

A single equals sign can check for a match from the beginning.

A double equals sign is used for exact equality.

Fixed-width fields must be trimmed.

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