0% found this document useful (0 votes)
17 views1 page

Delphi String Operations With Comments

The document provides examples of string manipulation in a programming context, including combining strings, converting characters to ASCII values, counting string length, and changing letter case. It also explains the difference between a character and a string, illustrating how to access individual characters from a string. The examples demonstrate the use of various functions like Chr, Ord, Length, UpperCase, and LowerCase.

Uploaded by

twitchgamer136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Delphi String Operations With Comments

The document provides examples of string manipulation in a programming context, including combining strings, converting characters to ASCII values, counting string length, and changing letter case. It also explains the difference between a character and a string, illustrating how to access individual characters from a string. The examples demonstrate the use of various functions like Chr, Ord, Length, UpperCase, and LowerCase.

Uploaded by

twitchgamer136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Combine Strings

var
FullName: string;
begin
// Combine first and last name with a space in between using +
FullName := 'John' + ' ' + 'Doe';

// Display the full name


ShowMessage(FullName); // Output: John Doe
end;

Functions: chr, ord, length, upcase, uppercase, lowercase


var
ch: Char;
s: string;
begin
// Chr: convert ASCII value to character
ch := Chr(65); // ASCII 65 is 'A'
ShowMessage(ch); // Output: A

// Ord: convert character to ASCII value


ShowMessage(IntToStr(Ord('A'))); // Output: 65

// Length: count how many characters are in the string


s := 'Delphi';
ShowMessage(IntToStr(Length(s))); // Output: 6

// UpperCase and LowerCase: change letter case


ShowMessage(UpperCase(s)); // Output: DELPHI
ShowMessage(LowerCase(s)); // Output: delphi
end;

Difference between char and string


var
c: Char;
s: String;
begin
s := 'Hello'; // String = collection of characters
c := s[1]; // Char = single character, get the first one

// Display first character


ShowMessage(c); // Output: H
end;

You might also like