Program Lab_7; Uses crt, Dos; Type Info=Record Marka,Color,GosNumb,Fam,Name,Otch: String; End; Const MenuPunkt: Array[1..7] of string = ('„ฎก ขซฅญจฅ ง ฏจแจ', 'เฎแฌฎโเ', '‚๋กฎเ ไ ฉซ ', '1) ฎจแช ฏฎ ฌ เชฅ จ ๆขฅโใ', '2) ฎจแช ฏฎ ฃฎแญฎฌฅเใ', '3) ฎจแช ฏฎ ขซ คฅซ์ๆใ', '‚๋ๅฎค'); Var Punkt: Integer; FileName: String; i,j: Integer; Function Reg(S: String): String; Var i: Integer; Begin For i:=1 to Length(S) do If (S[i]>='a') and (S[i]<='z') then S[i]:=Chr(Ord(S[i])-32) Else If (S[i]>=' ') and (S[i]<='ฏ') then S[i]:=Chr(Ord(S[i])-32) Else If (S[i]>='เ') and (S[i]<='๏') then S[i]:=Chr(Ord(S[i])-80); Reg:=S; End; Function OneInAnother(S1,S2: String): boolean; Var Res:Boolean; i,j: Integer; Begin OneInAnother:=True; For i:=1 to Length(S1) do Begin j:=1; res:=False; While (j<=Length(s2)) and (Not res) do Begin If S1[i]=S2[j] then Res:=True; Inc(j); End; If Not Res then OneInAnother:=False; End; End; Procedure Cursor(on: Boolean); Var R: Registers; Begin R.AH:=1; If on then Begin R.CH:=6; R.CL:=7; End Else R.CH:=$20; INTR(16,R); End; Procedure Find1(Book: String); Var i: Word; F: File of Info; Inf: Info; Marka, Color: String; Key: Char; Begin Assign(F, Book); {$I-} Reset(F); {$I+} If IOResult=0 then Reset(F) Else Rewrite(F); Close(F); TextBackGround(2); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write('ฐ'); End; Write('PageDown, PageUp - เฎชเใโช , Enter - ‚๋ๅฎค'); Cursor(False); TextBackGround(2); Window(11,5,72,18); Clrscr; Reset(F); GotoXY(2,2); TextBackGround(2); TextColor(1); Write('PageDown, PageUp - เฎชเใโช , Enter - ‚๋ๅฎค'); TextBackGround(6); TextColor(15); Clrscr; GotoXY(3,2); WriteLn('‚ขฅคจโฅ ฌ เชใ  ขโฎฌฎกจซ๏:'); GotoXY(3,3); Cursor(True); ReadLn(Marka); Clrscr; GotoXY(3,2); WriteLn('‚ขฅคจโฅ ๆขฅโ  ขโฎฌฎกจซ๏:'); GotoXY(3,3); Cursor(True); ReadLn(Color); Clrscr; Cursor(False); GotoXY(3,2); Reset(F); WriteLn('‘ฏจแฎช ขซ คฅซ์ๆฅข ฏฎคๅฎค๏้จๅ ฏฎค ฎฏจแ ญจฅ  ขโฎฌฎกจซฅฉ'); While Not Eof(F) do Begin Read(F, Inf); If (Reg(Inf.Marka)=Reg(Marka)) and (Reg(Inf.Color)=Reg(Color)) then Begin GotoXY(3,WhereY+1); Write(Inf.Fam,' ',Inf.Name,' ',Inf.Otch); End; End; Repeat Key:=ReadKey; Until Key=#13; Clrscr; Close(F); Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; End; Procedure Find2(Book: String); Var i,j: Word; F: File of Info; Inf: Info; Num: String; Key: Char; Begin Assign(F, Book); {$I-} Reset(F); {$I+} If IOResult=0 then Reset(F) Else Rewrite(F); Close(F); TextBackGround(2); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write('ฐ'); End; Write('PageDown, PageUp - เฎชเใโช , Enter - ‚๋ๅฎค'); Cursor(False); TextBackGround(2); Window(11,5,72,18); Clrscr; Reset(F); GotoXY(2,2); TextBackGround(2); TextColor(1); Write('PageDown, PageUp - เฎชเใโช , Enter - ‚๋ๅฎค'); TextBackGround(6); TextColor(15); Clrscr; GotoXY(3,2); WriteLn('‚ขฅคจโฅ จงขฅแโญ๋ฅ งญ ชจ จง ฃฎแ. ญฎฌฅเ   ขโฎฌฎกจซ๏:'); GotoXY(3,3); Cursor(True); ReadLn(Num); Clrscr; Cursor(False); GotoXY(3,2); Reset(F); WriteLn('‘ฏจแฎช ขซ คฅซ์ๆฅข ฏฎคๅฎค๏้จๅ ฏฎค ฎฏจแ ญจฅ  ขโฎฌฎกจซฅฉ'); While Not Eof(F) do Begin Read(F, Inf); If OneInAnother(Reg(Num),Reg(Inf.GosNumb)) then Begin GotoXY(3,WhereY+1); Write(Inf.Fam,' ',Inf.Name,' ',Inf.Otch,'. ƒฎแ. ญฎฌฅเ  ขโฎ- ',Inf.GosNumb); End; End; Repeat Key:=ReadKey; Until Key=#13; Clrscr; Close(F); Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; End; Procedure Find3(Book: String); Var i: Word; F: File of Info; Inf: Info; Fam, Name, Otch: String; Key: Char; Begin Assign(F, Book); {$I-} Reset(F); {$I+} If IOResult=0 then Reset(F) Else Rewrite(F); Close(F); TextBackGround(2); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write('ฐ'); End; Write('PageDown, PageUp - เฎชเใโช , Enter - ‚๋ๅฎค'); Cursor(False); TextBackGround(2); Window(11,5,72,18); Clrscr; Reset(F); GotoXY(2,2); TextBackGround(2); TextColor(1); Write('PageDown, PageUp - เฎชเใโช , Enter - ‚๋ๅฎค'); TextBackGround(6); TextColor(15); Clrscr; GotoXY(3,2); WriteLn('‚ขฅคจโฅ ไ ฌจซจ๎ ขซ คฅซ์ๆ :'); GotoXY(3,3); Cursor(True); ReadLn(Fam); Clrscr; GotoXY(3,2); WriteLn('‚ขฅคจโฅ จฌ๏ ขซ คฅซ์ๆ :'); GotoXY(3,3); Cursor(True); ReadLn(Name); Clrscr; GotoXY(3,2); WriteLn('‚ขฅคจโฅ ฎโ็ฅแโขฎ ขซ คฅซ์ๆ :'); GotoXY(3,3); Cursor(True); ReadLn(Otch); Clrscr; Cursor(False); GotoXY(3,2); Reset(F); WriteLn('ˆญไฎเฌ ๆจ๏ ฎก  ขโฎฌฎกจซ๎'); While Not Eof(F) do Begin Read(F, Inf); If (Reg(Inf.Fam)=Reg(Fam)) and (Reg(Inf.Name)=Reg(Name)) and (Reg(Inf.Otch)=Reg(Otch)) then Begin GotoXY(3,WhereY+1); Write(Inf.Marka,', ๆขฅโ- ',Inf.Color,', ฃฎแ. ญฎฌฅเ- ',Inf.GosNumb); End; End; Repeat Key:=ReadKey; Until Key=#13; Clrscr; Close(F); Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; End; Procedure AddRec(Book: String); Var F: File of Info; Inf: Info; Num, Code: Integer; Begin Assign(F, Book); {$I-} Reset(F); {$I+} If IOResult=0 then Begin Reset(F); End Else Rewrite(F); TextBackGround(2); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write(#176); End; Write(' ง  ค ญญ๋ๅ ƒˆ„„'); TextBackGround(2); Window(19,9,59,14); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ฌ เชใ  ขโฎฌฎกจซ๏:'); GotoXY(4,4); ReadLn(Inf.Marka); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ๆขฅโ  ขโฎฌฎกจซ๏:'); GotoXY(4,4); ReadLn(Inf.Color); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ฃฎแ. ญฎฌฅเ  ขโฎฌฎกจซ๏:'); GotoXY(4,4); ReadLn(Inf.GosNumb); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ไ ฌจซจ๎ ขซ คฅซ์ๆ :'); GotoXY(4,4); ReadLn(Inf.Fam); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(3,2); WriteLn('‚ขฅคจโฅ จฌ๏ ขซ คฅซ์ๆ '); GotoXY(4,4); ReadLn(Inf.Name); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(3,2); WriteLn('‚ขฅคจโฅ ฎโ็ฅแโขฎ ขซ คฅซ์ๆ '); GotoXY(4,4); ReadLn(Inf.Otch); Clrscr; Seek(F, FileSize(F)); Write(F,Inf); Close(F); Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; End; Procedure FileChoise(Var Name: String); Var F: File of Info; Begin TextBackGround(2); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write(#176); End; Write(' ง  ค ญญ๋ๅ ƒˆ„„'); TextBackGround(2); Window(19,9,59,14); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(4,2); WriteLn('‚ขฅคจโฅ จฌ๏ ไ ฉซ '); GotoXY(3,4); Read(Name); Assign(F, Name); {$I-} Reset(F); {$I+} If IOResult<>0 then Rewrite(F); If FileSize(F)=0 then Begin Seek(F,0); Truncate(F); End; Close(F); Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; End; Procedure View(Book: String); Const Null: String = ' '; Var F: File of Info; Inf, Temp: Info; Page, i, Pos, Pos1: Word; Key: Char; Items: Array[0..11] of String; Num, Code: Integer; St,St1: String; Begin Assign(F, Book); TextBackGround(2); Clrscr; Page:=1; For i:=0 to 11 do Items[i]:=''; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write(#176); End; Write('PageDown, PageUp - เฎชเใโช , Esc - ‚๋ๅฎค, Enter - ˆงฌฅญจโ์ ง ฏจแ์, Del - “ค ซจโ์ ง ฏจแ์'); Cursor(False); TextBackGround(2); Window(6,5,74,18); Clrscr; Pos:=0; Repeat {$I-} Reset(F); {$I+} If IOResult<>0 then Rewrite(F); Clrscr; GotoXY(1,2); TextBackGround(6); TextColor(0); WriteLn(' Œ เช  บ–ขฅโ บƒฎแ. ญฎฌฅเ บ” ฌ. ขซ ค. บˆฌ๏. ขซ ค. บŽโ็. ขซ ค. '); TextBackGround(2); TextColor(0); i:=0; While (Not Eof(F)) and (i<=Page*11) do Begin Inc(i); Read(F, Inf); If (i>=Page*11-10) and (i<=Page*11) then Begin With Inf do Begin If Length(Marka)<=9 then Begin Write(' '+Marka+Copy(Null,1,9-Length(Marka))+'บ'); Items[i-(Page*11-11)-1]:=' '+Marka+ Copy(Null,1,9-Length(Marka))+'บ'; End Else Begin Write(' '+Copy(Marka,1,6)+'...บ'); Items[i-(Page*11-11)-1]:=' '+Copy(Marka,1,6)+'...บ'; End; If Length(Color)<=8 then Begin Write(' '+Color+Copy(Null,1,8-Length(Color))+'บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Color+ Copy(Null,1,8-Length(Color))+'บ'; End Else Begin Write(' '+Copy(Color,1,5)+'...บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Copy(Color,1,5)+'...บ'; End; If Length(GosNumb)<=10 then Begin Write(' '+GosNumb+Copy(Null,1,10-Length(GosNumb))+'บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+GosNumb+ Copy(Null,1,10-Length(GosNumb))+'บ'; End Else Begin Write(' '+Copy(GosNumb,1,7)+'...บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Copy(GosNumb,1,7)+'...บ'; End; If Length(Fam)<=10 then Begin Write(' '+Fam+Copy(Null,1,10-Length(Fam))+'บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Fam+ Copy(Null,1,10-Length(Fam))+'บ'; End Else Begin Write(' '+Copy(Fam,1,7)+'...บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Copy(Fam,1,7)+'...บ'; End; If Length(Name)<=10 then Begin Write(' '+Name+Copy(Null,1,10-Length(Name))+'บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Name+ Copy(Null,1,10-Length(Name))+'บ'; End Else Begin Write(' '+Copy(Name,1,7)+'...บ'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Copy(Name,1,7)+'...บ'; End; If Length(Otch)<=10 then Begin WriteLn(' '+Otch+Copy(Null,1,10-Length(Otch))); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Otch+ Copy(Null,1,10-Length(Otch)); End Else Begin WriteLn(' '+Copy(Otch,1,7)+'...'); Items[i-(Page*11-11)-1]:=Items[i-(Page*11-11)-1]+' '+Copy(Otch,1,7)+'...'; End; End; End; End; TextBackGround(6); TextColor(15); GotoXY(1,pos mod 11 + 3); Write(Items[Pos mod 11]); TextBackGround(2); key:=ReadKey; If Ord(Key)=0 then Begin key:=ReadKey; If key=#81 then If Not Eof(F) then Begin Inc(Page); Pos:=Page*11-11; End; If key=#73 then If Page<>1 then Begin Dec(Page); Pos:=Page*11-11; End; If Ord(Key)=80 then If (Pos = Page*11-1) or (Pos>=i-1) then Pos:=Page*11-11 Else Pos:=Pos+1; If Ord(Key)=72 then If (Pos =Page*11-11) then Begin If i>=Page*11 then Pos:=Page*11-1 Else Pos:=i-1; End Else Pos:=Pos-1; If Key=#83 then Begin Reset(F); i:=0; While Not Eof(F) do Begin Read(F, Inf); Inc(i); End; If Pos<>FileSize(F)-1 then Begin Pos1:=Pos; Seek(F,Pos+1); While Not Eof(F) do Begin Read(F, Inf); Seek(F, Pos1); Write(F, Inf); Seek(F, Pos1+2); Inc(Pos1); If Pos1>=i-1 then Begin Seek(F, Pos1); Truncate(F); End; End; End Else Begin Seek(F, Pos); Truncate(F); Pos:=Pos-1; End; Close(F); If Page*11-11>Pos then Page:=Page-1; Reset(F); If FileSize(F)=0 then For i:=0 to 11 do Begin Items[i]:=''; Key:=#27; End; End; End; If (Key=#13) and (FileSize(F)<>0) then Begin Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); TextBackGround(2); Window(19,9,59,14); Seek(F,Pos); Read(F,Inf); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ฌ เชใ  ขโฎฌฎกจซ๏:'); GotoXY(4,4); ReadLn(Inf.Marka); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ๆขฅโ  ขโฎฌฎกจซ๏:'); GotoXY(4,4); ReadLn(Inf.Color); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ฃฎแ. ญฎฌฅเ  ขโฎฌฎกจซ๏:'); GotoXY(4,4); ReadLn(Inf.GosNumb); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(10,2); WriteLn('‚ขฅคจโฅ ไ ฌจซจ๎ ขซ คฅซ์ๆ :'); GotoXY(4,4); ReadLn(Inf.Fam); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(3,2); WriteLn('‚ขฅคจโฅ จฌ๏ ขซ คฅซ์ๆ '); GotoXY(4,4); ReadLn(Inf.Name); Clrscr; WriteLn('ษออออออออออออออออออออออออออออออออออออออป'); For i:=2 to 5 do WriteLn ('บ บ'); Write('ศออออออออออออออออออออออออออออออออออออออผ'); GotoXY(3,2); WriteLn('‚ขฅคจโฅ ฎโ็ฅแโขฎ ขซ คฅซ์ๆ '); GotoXY(4,4); ReadLn(Inf.Otch); Seek(F,Pos); Write(F,Inf); Close(F); Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; TextBackGround(2); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write(#176); End; Write('PageDown, PageUp - เฎชเใโช , Esc - ‚๋ๅฎค, Enter - ˆงฌฅญจโ์ ง ฏจแ์, Del - “ค ซจโ์ ง ฏจแ์'); Cursor(False); TextBackGround(2); Window(6,5,74,18); Clrscr; End; Until key=#27; Close(F); Window(1,1,80,25); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; End; Procedure Menu(Var pos: Integer); Var i: Integer; Key: Char; Begin TextBackGround(2); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write(#176); End; Write(' ง  ค ญญ๋ๅ ƒˆ„„'); TextBackGround(6); Window(18,8,66,16); Clrscr; TextColor(7); GotoXY(1,1); Write('ษอออออออออออออออออออออออออออออออออออออออออออออออป'); For i:=1 to 7 do Begin GotoXY(1,i+1); Write('บ บ'); End; Window(18,8,66,18); GotoXY(1,9); Write('ศอออออออออออออออออออออออออออออออออออออออออออออออผ'); For i:=1 to 7 do Begin GotoXY(4,i+1); Write(MenuPunkt[i]); End; TextBackGround(3); TextColor(1); GotoXY(4,pos+1); Write(MenuPunkt[pos]); Cursor(false); Repeat Key:= ReadKey; If Ord(Key)<>13 then Begin TextBackGround(6); TextColor(7); GotoXY(4,pos+1); Write(MenuPunkt[pos]); If Ord(key)=0 then Begin Key:=ReadKey; If Ord(Key)=80 then If Pos=7 then Pos:=1 Else Pos:=Pos+1; If Ord(Key)=72 then If Pos=1 then Pos:=7 Else Pos:=Pos-1; End; TextBackGround(3); TextColor(1); GotoXY(4,pos+1); Write(MenuPunkt[pos]); End; Until Key=chr(13); Window(1,1,80,25); Cursor(true); TextBackGround(0); TextColor(15); TextColor(15); Clrscr; End; Begin TextBackGround(1); Clrscr; For i:=1 to 24 do For j:=1 to 80 do Begin GotoXY(j,i); Write(#176); End; Write(' ง  ค ญญ๋ๅ ƒˆ„„'); Punkt:=1; FileName:='baze.dat'; Repeat Menu(Punkt); Case Punkt of 1: AddRec(FileName); 2: View(FileName); 3: FileChoise(FileName); 4: Find1(FileName); 5: Find2(FileName); 6: Find3(FileName); 7: ; End; Until Punkt=7; End.