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];