Home > Articles

  • Print
  • + Share This
This chapter is from the book

Strings

key_topic_icon.jpg

A string is a series of characters that is interpreted literally by a script, such as “Abraham Lincoln” or “THX1138.” Computer programs usually connect a string to a variable. For example:

$string = "This is a string"
Print "The value of $string is " $string
Output:
The value of $string is This is a string

In this example, the variable $string is assigned the value "This is a string". Then, the second line prints “The value of $string is This is a string” when the script is run.

The amount of space set aside for a string can be variable (enabling strings of various lengths) or fixed. If a string has a length of 11 characters, but you attempt to enter more than 11 characters, the last characters will be left off. This is called truncation. Figure 3-1 illustrates an example of this problem.

key_topic_icon.jpg
Figure 3-1

Figure 3-1 Example of a Truncation

When data entry systems are designed to use fixed-size strings, watch out for truncation like this example. Data entry designers need to take into account both typical and larger examples of proper names or other data when sizing data entry fields.

  • + Share This
  • 🔖 Save To Your Account