Delphi Language Learning 4-Basic use of data types

Source: Internet
Author: User
Tags ord

1. Basic data types

1 delphi with some basic types of operation functions, such as Ord, PRED,SUCC, High,low

2) enumeration type

Declaration Type Suit = (club, Diamond, Heart, Spade)//where Ord (club) returns 0, ORD (Diamond) returns 1 ...

If the name of the enumerated type and the type name are used repeatedly:

Type Tsound = (Click, clack, Clock)
Procedure Tform1.dbgridenter (Sender:tobject);
var Thing:tsound;
Begin
...
Thing: = Myunit.click;
End

Specifying the value of an enumeration type

Example 1
Type Size = (Small = 5, Medium = ten, Large = Small + Medium);
var x:size;
X: = Small; Ord (X) = 5
Y: = Size (6); Ord (X) = 6
INC (X); Ord (X) = 7
Example 2
Type Someenum = (e1, e2, E3 = 1)//ord (E1) returns 0, ORD (E2) returns 1, and Ord (E3) also returns 1;

3) Interval type (Subrange Types)

Declaration mode

Type
Somenumbers = -128..127;
Caps = ' A ' ... ' Z ';

2. Strings and characters

Convert string to uppercase

var I:integer;
Begin
I: = Length (MyString);
While I > 0 do
Begin
Mystring[i]: = Ansiuppercase (Mystring[i]);
I: = I-1;
End
End

String Assignment

MyString: = ' Hello world! ';
MyString: = ' Hello ' + ' world ';
MyString: = MyString + '! ';
MyString: = '; {Space}
MyString: = '; {Empty string}

Short strings range 0 to 255

Using pointers

Const TEMPSTRING:ARRAY[0..12] of Char = ' Hello world! ';
var P:pchar;
...
P: = @TempString [0];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.