8.
, ,
Delphi , , ( ).
AnsiChar WideChar. AnsiChar ANSI-, 8- (). WideChar Unicode, . Char, AnsiChar.
:
var _: char;
.
:
var otv: char; ch: char;
...
otv:='y'; ch:='';
, #, , '' #193. , , , , #13.
(<, <=, =, >, >=, <>), .
Chr, , , Ord, , .
, c:=chr(32) k:=ord('*') k 42 *.
Pred Succ, , pred('b') => 'a' succ('b') => 'c'.
, . , , .
:
1. , :
Const d: array[1..10] of char = ('0','1','2','3','4','5','6','7','8','9');
, , :
Const d: array[1..10] of char = '0123456789';
2. , , :
var s: array[1..11] of char;
s:=' ';
3. , .. :
var s: array[1..10] of char;...
for i:=1 to 10 do Read(s[i]); { ABCDE FILN}
4. , , - , Write WriteLn:
|
|
WriteLn(s); { }
5. () , +. , , - , :
WriteLn(st1 + ' ' + st2); { }
, .
1. Pascal ABC.
40 , , , . . , .
- . , .. , . . , , , , . , , , .
, . , , , . , , . , , .
:
, , , . , , : , , . - , .
ShortString, AnsiString WideString, , .
ShortString , .. , 255. AnsiString WideString , .
String, ShortString.
, , , :
- , :
var S1, S2: string[40]; { 40 }
name: string[30]; { 30 }
buff: string; { 255 }
|
|
- , :
S40 = string[40]; { - 40 }
STR = string; { - 255 }
var S1, S2: S40; { S40}
S3: STR; { ST}
C , 0 , . .. 1 .
.
, - , :
Const S: string[40] = ' ';
s1: string= ''; { }
.
, , , () .
. , .. , st[1] s[i]. , - , . . , i - , S3 - , S3 :
1) i:=byte(S3[0]); { }
2) i:=ord(S3[0]); { }
, Length.
. . -, :
S1:= 'ABCD'; { }
S2:= ''; { }
S:=S1; { }
. - , -.
. . , . :
'fdc' + 'ghj'; { ' fdcghj'}
S4 + 'vvv'; { S4 'vvv'}
- .
. : =, <>, >, <, >=, <=. . , ASCII . , #0. false true. , .,
S4:='ABCD'; S3:='ADFH'; C:='L';
:
S4 = S3 { false}
S4 > S3 { false}
S3 > S4 { true}
S3 = { false}
- . - Read (ReadLn) Write (WriteLn), : ReadLn(S1); WriteLn(S1);
ENTER. , , . . .. ENTER, , , , . Enter, , , .
|
|
Delphi .
Length
Length(S): Integer . .
:
var Str: string; Index: Integer;
begin
Str:='';
index:= Length(Str);
end;
str () index ( ). str "". index str. , index, 6 .
Delete
Delete(var S: string; Index, Count: Integer) S. Index - , , Count - .
:
var Str: string;
begin
Str:= ' -';
Delete(Str, 7, 6);
end;
str 7- 12- (6 , 7- ). str ' '.
Pos
Pos(Substr: string; S: string): Integer Substr S. , , . , 0.
:
var Str: string;
begin
Str:= '-';
index:=Pos('', Str);
end;
'' str. index 7.
while, st.
while (pos(' ',st) = 1) and (length(st) > 0) do delete (st,1,1);
delete (st,1, 1), , ( s(' ',st) 1). length(st)>0 , .
Copy(S; Index, Count: Integer): string S count , index.
:
var Str1: string; Str2: string;
begin
Str1:= ' ';
Str2:=Copy(Str1, 9, 6);
end;
str2 6- str1, 9- . str2 ''.
Insert
Insert(Source: string; var S: string; Index: Integer) Source S, index. , , .
:
var Str: string;
begin
Str:= ' ';
Insert(' ', Str, 6);
end;
str ' ', 6- . ' '.
Str
Str(x[:w [:d]], St) - x st, ( ).
w, , , d, - , :
:=-5.67;
Str(x:7:3,s1); { ' -5.670'}
, .
Val
|
|
Val(St, , Code) - St . Code : 0, , , st . , , :
Var S:string; Code:integer; a:real;...
...repeat
Write(' a:');
ReadLn(S); { }
Val(S, a, Code); { }
if Code <> 0 then WriteLn(' ');
until Code=0;... { }
UpCase
UpCase(ch):char - , ch, , ch, .