Pascal Strings
Pascal Strings
The string in Pascal is actually a sequence of characters with an optional size specification. The
characters could be numeric, letters, blank, special characters or a combination of all. Extended
Pascal provides numerous types of string objects depending upon the system and implementation.
We will discuss more common types of strings used in programs.
Character arrays − This is a character string which is a sequence of zero or more byte-sized
characters enclosed in single quotes.
Examples
The following program prints first four kinds of strings. We will use AnsiStrings in the next example.
program exString;
var
greetings: string;
name: packed array [1..10] of char;
organisation: string[10];
message: pchar;
begin
greetings := 'Hello ';
message := 'Good Day!';
When the above code is compiled and executed, it produces the following result −
program exString;
uses sysutils;
var
str1, str2, str3 : ansistring;
str4: string;
len: integer;
begin
str1 := 'Hello ';
str2 := 'There!';
When the above code is compiled and executed, it produces the following result −
1
function AnsiCompareStrconstS1: ; constS2: :Integer;
2
function AnsiCompareTextconstS1: ; constS2: :Integer;
3
function AnsiExtractQuotedStrvarSrc: PChar; Quote: Char:;
4
function AnsiLastCharconstS: :PChar;
5
function AnsiLowerCaseconsts: :
6
function AnsiQuotedStrconstS: ; Quote: Char:;
Quotes a string
7
function AnsiStrCompS1: PChar; S2: PChar:Integer;
8
function AnsiStrICompS1: PChar; S2: PChar:Integer;
9
function AnsiStrLCompS1: PChar; S2: PChar; MaxLen: Cardinal:Integer;
10
function AnsiStrLICompS1: PChar; S2: PChar; MaxLen: Cardinal:Integer;
11
function AnsiStrLastCharStr: PChar:PChar;
12
function AnsiStrLowerStr: PChar:PChar;
13
function AnsiStrUpperStr: PChar:PChar;
14
function AnsiUpperCaseconsts: :;
15
procedure AppendStrvarDest: ; constS: ;
Appends 2 strings
16
procedure AssignStrvarP : PString; constS: ;
17
function CompareStrconstS1: ; constS2: :Integer; overload;
18
function CompareTextconstS1: ; constS2: :Integer;
Compares two strings case insensitive
20
procedure DisposeStrS: PShortString; overload;
21
function IsValidIdentconstIdent: :Boolean;
22
function LastDelimiterconstDelimiters: ; constS: :Integer;
23
function LeftStrconstS: ; Count: Integer:;
24
function LoadStrIdent: Integer:;
25
function LowerCaseconsts: :; overload;
26
function LowerCaseconstV: variant:; overload;
27
function NewStrconstS: :PString; overload;
28
function RightStrconstS: ; Count: Integer:;
29
function StrAllocSize: Cardinal:PChar;
30
function StrBufSizeStr: PChar:SizeUInt;
Reserves memory for a string
31
procedure StrDisposeStr: PChar;
32
function StrPasStr: PChar:;
33
function StrPCopyDest: PChar; Source: :PChar;
34
function StrPLCopyDest: PChar; Source: ; MaxLen: SizeUInt:PChar;
35
function UpperCaseconsts: :;