System.ShortString

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

type ShortString = string[255];

C++

typedef SmallString<255>     ShortString;      //

Properties

Type Visibility Source Unit Parent
type
typedef
public
System.pas
sysmac.h
System System

Description

Represents a string whose maximum length is 255 characters.

A ShortString is 0 to 255 single-byte characters long. While the length of a ShortString can change dynamically, its memory is a statically allocated 256 bytes; the first byte stores the length of the string, and the remaining 255 bytes are available for characters. If S is a ShortString variable, Ord(S[0]), like Length(S), returns the length of S; assigning a value to S[0], like calling SetLength, changes the length of S. ShortString is maintained for backward compatibility only.

The Object Pascal language supports short-string types--in effect, subtypes of ShortString--whose maximum length is anywhere from 0 through 255 characters. These are denoted by a bracketed numeral appended to the reserved word string.

When you assign a value to a ShortString variable, the string is truncated if it exceeds the maximum length for the type.

Note: ShortString is used by the Object Pascal desktop compilers, but is not supported by the Object Pascal mobile compilers. For more information, see Migrating Object Pascal Code to Mobile from Desktop.

See Also

Code Examples