. , , ,

,,,

Turbo Pascal — ,

 

-

( -

) -

1 255.

Length.

┌──────┐

───>│string├──┬──────────────────────────────>

└──────┘ │ ^

│ ┌───┐ ┌─────┐ ┌───┐ │

└─>│ [ ├──>│├──>│ ] ├─┘

└───┘ │ │ └───┘

││

└─────┘

-

. -

-

""; , 'Xs' ,

'X'.

, .

Low High.

Low 0, High

( ) .

-,

OpenString string {$P+},

. -

.

, ,


.

-

, -

, .

┌───┐ ┌─────────┐ ┌───┐

──>│ [ ├───────>│├────┬──>│ ] ├──>

└───┘ ^ └─────────┘ │ └───┘

│ ┌───┐ │

└───────┤ , │<───────┘

└───┘

.

. , -

.

. :

Matrix[I][J]

:

Matrix[I,J]

-

, -

0...n, n - .

,

Char.

( 0) -

, Length(S) Ord(S[0]).

, -

, -


.

. ,

-

.

{$X+} -

, PChar

Word. -

,

Char.

-

.

-

:

- OpenString;

- string {$P+}.

OpenString System.

, -

. -

OpenString -

, , , -

.

, -

string

{$P+}. {$P+} , -

string, .

-

. -

( )

, .

-


- ,

. ,

.

S AssignStr -

:

procedure AssignStr(var S: OpenString);

begin

S := '0123456789ABCDEF';

end;

S - , AssignStr

:

var

S1: string[10];

S1: string[20];

begin

AssignStr(S1); { S1 := '0123456789' }

AssignStr(S2); { S2 := '0123456789ABCDEF' }

end;

AssingStr S ,

. , ⠠ 젠

AssingStr S ,

S1 10.

Low 0, High

,

SizeOf .

FillString

.

High -

.


procedure FillStr(var S: OpenString; Ch: Char);

begin

S[0] := Chr(High(S)); { }

FillChar(S[1], High(S), Ch); {

}

end;

-,

OpenString string

{$P+}, .

, -

255, Hingh

255.


uses crt,dos;

var i,j,i1,x:integer;

DI: SearchRec;

textf:array[1..800] of string[79];

procedure music;

begin

sound(800);

delay(200);

nosound;

end;

procedure myerror (s:string);

var c:char;

begin

textbackground(4);

window(10,10,70,16);

clrscr;

textcolor(15);

write('╔════════════════════════ ═════════════════════════╗');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('╚═══════════════════════════════════════════════════════════╝');

gotoxy(10,2);

write(' ',s,'.');

gotoxy(15,3);

write(' .');

textbackground(1);

gotoxy(27,5);

write(' ');

c:=chr(1);

{ }

music;

while(c<>chr(13)) do

c:=readkey;

end;

procedure ins(x,y,w:integer;ct,ft:integer);

var l,i:integer;

attr:byte;

begin

attr:=ct+16*ft;

if lastmode=co40 then l:=y*80+2*x+1;

if lastmode=co80 then l:=y*160+2*x+1;

i:=l;

while (i

begin

mem[$b800:i]:=attr;

i:=i+2;

end;

end;

procedure hide;

var r:registers;

begin

r.ah:=$01;

r.ch:=$20;

r.cl:=$00;

intr($10,r);

end;

function myexit:boolean;

var c:char;

i,x:integer;

begin

window(20,8,55,13);

textbackground(7);

textcolor(0);

write('╔═══════ ════════╗');

write('║ ║');

write('║ ║');

write('║ ║');

write('╚══════════════════════════════════╝');

textbackground(6);

gotoxy(8,3);

write(' ࠠ ' );

textbackground(3);

gotoxy(21,3);

write(' ');

ins(20,12,36,7,0);

ins(55,12,1,7,0);

ins(55,11,1,7,0);

ins(55,10,1,7,0);

ins(55,9,1,7,0);

ins(55,8,1,7,0);

c:=chr(1);

i:=1;

x:=26;

while(c<>chr(13)) do

begin

c:=readkey;

{ ESC }

if c=chr(27) then begin i:=2;break;end;

if c=chr(0) then begin

c:=readkey;

ins(x,9,7,15,3);

if c=chr(77) then if i=2 then begin x:=26;i:=1;end

else begin x:=39;i:=2;end;

if c=chr(75) then if i=2 then begin x:=26;i:=1;end

else begin x:=39;i:=2;end;

ins(x,9,7,15,6);

end;

end;

case i of

1:myexit:=true;

2:myexit:=false;

end;

end;

procedure obuch;

var n,c:char;

s,zx:string;

t:boolean;

y,x,y1,m:integer;

f:text;

begin

window(1,1,80,25);

textbackground(0);

clrscr;

hide;

m:=1;i:=1;

window(1,1,80,2);

textbackground(2);

clrscr;

textcolor(5);

write(' 21');

gotoxy(20,1);

window(1,23,80,24);

textbackground(2);

clrscr;

window(1,2,80,23);

textbackground(1);

clrscr;

textbackground(7);

window(1,1,80,25);

gotoxy(20,1);

gotoxy(2,24);

write(' ',char(24),' - ');

gotoxy(14,24);

write(' ',char(25),' - ');

gotoxy(25,24);

write(' PgUp - ');

gotoxy(45,24);

write(' PgDn - ');

gotoxy(65,24);

write(' ESC - ');

textbackground(1);

textcolor(15);

window(1,2,80,23);

assign(f,'curswork.txt');

reset(f);

while((i=1)and(m<796)) do

begin

readln(f,s);

if (s[1]='#')and(s[2]='#')and(s[3]='#') then break;

textf[m]:=s;

if m<22 then writeln(s);

m:=m+1;

end;

x:=m;

c:=chr(1);

m:=0;

while c<>chr(27) do

begin

c:=readkey;

if c=chr(27) then if myexit then c:=chr(27) else begin

c:=chr(1);

window(1,2,80,23);

textbackground(1);

clrscr;

textcolor(15);

for i:=m to m+21 do

begin

writeln(textf[i]);

end;

end;

if c=chr(0) then begin

c:=readkey;

if ((c=chr(81))) then if (m+23<=x-23) then m:=m+21 else m:=x-21;

if ((c=chr(73))) then if (m-23>1) then m:=m-21 else m:=0;

if ((c=chr(80)) and (x-23>=m)) then m:=m+1;

if ((c=chr(72)) and (m>0))then m:=m-1;

clrscr;

for i:=m to m+21 do

begin

writeln(textf[i]);

end;

window(1,1,80,25);

gotoxy(1,1);

textbackground(2);

textcolor(5);

write(' ');

gotoxy(1,1);

write(' ',m+1);

window(1,2,80,23);

textcolor(15);

textbackground(1);

end;

end;

textbackground(0);

window(1,1,80,25);

clrscr;

end;

function select:integer;

var om:integer;

c:char;

begin

om:=lastmode;

textmode(co40);

textbackground(0);

hide;

window(5,3,35,20);

textbackground(1);

clrscr;

textcolor(15);

window(1,1,40,25);

gotoxy(1,3);

for i:=5 to 35 do

begin

gotoxy(i,5);

write('═');

gotoxy(i,20);

write('═');

end;

for i:=5 to 20 do

begin

gotoxy(5,i);

write('║');

gotoxy(35,i);

write('║');

end;

gotoxy(5,20);

write('╚');

gotoxy(5,5);

write('╔');

gotoxy(35,20);

write('╝');

gotoxy(35,5);

write('╗');

textcolor(5);

gotoxy(5,3);

write(' TP 7.0 ');

textcolor(15);

gotoxy(12,8);

write('');

gotoxy(12,10);

write('');

gotoxy(12,12);

write(' ');

gotoxy(12,14);

write('');

ins(5,x,29,1,2);

c:=chr(1);

while(c<>chr(13)) do

begin

c:=readkey;

if c=chr(0) then begin

c:=readkey;

ins(5,x,29,15,1);

if c=chr(80) then

if i1=4 then begin x:=7;i1:=1;end

else begin x:=x+2;i1:=i1+1; end;

if c=chr(72) then

if i1=1 then begin x:=13;i1:=4;end

else begin x:=x-2;i1:=i1-1; end;

ins(5,x,29,1,2);

end;

end;

textmode(om);

case (i1) of

1:select:=1;

2:select:=2;

3:select:=3;

4:select:=4;

end;

end;

procedure help;

var s:string;

f:text;

i:byte;

begin

textmode(co80);

hide;

window(10,5,70,20);

textbackground(1);

textcolor(15);

clrscr;

write('╔═══════════════════════ ═══════════════════════════╗');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ࠠ ║');

write('╚═══════════════════════════════════════════════════════════╝');

assign(f,'help.txt');

reset(f); i:=2;

while not(eof(f)) do

begin

gotoxy(2,i);

readln(f,s);

if ((s[1]='#') and (s[2]='#')) then break;

writeln(s);

i:=i+1;

end;

close(f);

readkey;

end;

procedure about;

var f:text;

q:byte;

s:string;

begin

textmode(co80);

hide;

window(10,5,70,20);

textbackground(1);

textcolor(15);

clrscr;

write('╔═════════════════════ Π ════════════════════════╗');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ║');

write('║ ࠠ ║');

write('╚═══════════════════════════════════════════════════════════╝');

assign(f,'about.txt');

reset(f);

q:=2;

while not(eof(f)) do

begin

gotoxy(2,q);

readln(f,s);

if ((s[1]='#') and (s[2]='#')) then break;

writeln(' ',s);

q:=q+1;

end;

close(f);

readkey;

end;

begin

hide;

findfirst('curswork.txt',anyfile,di);

if doserror<>0 then begin

myerror('curswork.txt');

halt(1);

end;

findfirst('help.txt',anyfile,di);

if doserror<>0 then begin

myerror('help.txt');

halt(1);

end;

findfirst('about.txt',anyfile,di);

if doserror<>0 then begin

myerror('about.txt');

halt(1);

end;

j:=1;

i1:=1;

x:=7;

while j=1 do

begin

i:=select;

case i of

1:obuch;

2:help;

3:about;

4:begin textbackground(0);clrscr;halt;end;

end;

end;

end.

- ( -

 

 

 

! , , , .
. , :