program practyka1; uses crt; type firm=record {invariant part} name:string[8]; model:string[6]; giver:string[10]; {variant part} {for cars} year:string[4]; colour:string[7]; {for processors} processor:string[10]; memory:string[7]; end;{firm=record} label start,next,search,next1,next3,name1,model1,giver1,year1,colour1,processor1,memory1; const x:array[1..10] of char=('0','1','2','3','4','5','6','7','8','9'); w:array[1..26] of char=('a','b','c','d','e','f','g','h','i','j', 'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); var f1:text; i,j,n,q,h,d,cnt:integer; flag,flag1,flag2,flag3:boolean; r:array[1..50] of string; s,a,b:string; k,l,o:integer; c,p:char; goods:array[1..50] of firm; procedure table; begin writeln(' -------Goods of the firm----'); for i:=1 to 60 do write('-'); writeln; write('Name |'); write(' Model|'); write(' Giver |'); write(' Year|'); write(' Colour|'); write(' Processor|'); writeln(' Memory|'); for i:=1 to 60 do write('-'); writeln; end; procedure reading; begin Reset(f1); i:=1; while not eof(f1) do with goods[i] do begin readln(f1,s); k:=pos(' ',s); Name:=copy(s,1,k); delete(s,1,k); k:=pos(' ',s); Model:=copy(s,1,k); delete(s,1,k); k:=pos(' ',s); Giver:=copy(s,1,k); delete(s,1,k); k:=pos(' ',s); Year:=copy(s,1,k); delete(s,1,k); k:=pos(' ',s); colour:=copy(s,1,k); delete(s,1,k); k:=pos(' ',s); processor:=copy(s,1,k); delete(s,1,k); k:=pos(' ',s); memory:=copy(s,1,k); delete(s,1,k); i:=i+1; end;{with} end; procedure monitor(i:integer); begin with goods[i] do begin write(Name); for j:=1 to (8-length(Name)) do write(' '); write('|'); write(' ',model); for j:=1 to (5-length(Model)) do write(' '); write('|'); write(' ',giver); for j:=1 to (9-length(giver)) do write(' '); write('|'); if (year='0')or(year='0 ') then begin write('-'); for j:=1 to 4 do write(' '); end else begin write(year,' '); for j:=1 to (4-length(year)) do write(' '); end; write('|'); if (colour='0')or(colour='0 ') then begin write('-'); for j:=1 to 6 do write(' '); write('|'); end{if} else begin write(colour,' '); for j:=1 to (6-length(colour)) do write(' '); write('|'); end;{else} if (processor='0')or(processor='0 ') then begin write('-'); for j:=1 to 9 do write(' '); write('|'); end{if} else begin write(processor,' '); for j:=1 to (9-length(processor)) do write(' '); write('|'); end;{else} if (memory='0')or(memory='0 ') then begin write('-'); for j:=1 to 6 do write(' '); writeln('|'); end{if} else begin write(memory,' '); for j:=1 to (6-length(memory)) do write(' '); writeln('|'); end;{else} end;{with goods[i]} end; procedure datafile; begin clrscr; table; reading; for i:=1 to n-1 do monitor(i); end; procedure thing; begin clrscr; table; monitor(k); end; begin clrscr; assign(f1,'C:\Pask\fac1.dat'); reading; n:=i; start: writeln; writeln('1 - enter all data file on the monitor'); writeln('2 - enter on the monitor information about one thing'); writeln('3 - enter new notation'); writeln('4 - delete notation'); writeln('5 - exit'); c:=readkey; case c of '1': begin datafile; goto start; end;{'1':} '2': begin clrscr; search: writeln; writeln('n - search for name'); writeln('m - search for model'); writeln('g - search for giver'); writeln('y - search for year'); writeln('c - search for colour'); writeln('p - search for processor'); writeln('r - search for memory'); writeln('e - exit to main menu'); p:=readkey; case p of 'n':begin write('Enter name of one of the goods: '); readln(a); cnt:=0; for i:=1 to n-1 do if(goods[i].name= a) then begin thing; cnt:=cnt+1; goto search; end else writeln('There is no such thing in database!'); goto search; end; 'm':begin write('Enter model of the thing:'); readln(a); for k:=1 to n-1 do with goods[k] do if model=a then begin thing; flag3:=true; goto next3; end;{if} if not flag then writeln('There is no such thing in data base!'); goto search; next3: for q:=k+1 to n-1 do with goods[q] do if model=a then monitor(q); goto search; end;{'m':} 'g':begin write('Enter giver of one of the goods: '); readln(a); for k:=1 to n-1 do with goods[k] do if giver=a then begin thing; goto search; end;{if} writeln('There is no such thing in data base!'); goto search; end;{'g':} 'y':begin write('Enter year of the car: '); readln(a); for k:=1 to n-1 do with goods[k] do if year=a then begin thing;flag2:=true; goto next; end;{if} if not flag then writeln('There is no such car in data base!'); goto search; next: for q:=k+1 to n-1 do with goods[q] do if year=a then monitor(q); goto search; end;{'y':} 'c':begin write('Enter colour of the car: '); readln(a); for k:=1 to n-1 do with goods[k] do if colour=a then begin thing; goto search; end;{if} writeln('There is no such car in data base!'); goto search; end;{'c':} 'p':begin write('Enter type of the processor of the computer: '); readln(a); for k:=1 to n-1 do with goods[k] do if processor=a then begin thing; goto search; end;{if} writeln('There is no such computer in data base!'); goto search; end;{'p':} 'r':begin write('Enter type of the memory of the computer: '); readln(a); for k:=1 to n-1 do with goods[k] do if memory=a then begin thing; goto search; end;{if} writeln('There is no such computer in data base!'); goto search; end;{'r':} 'e':begin clrscr; goto start; end;{'e':} else begin clrscr; writeln('You pressed wrong key! Try again.'); goto search; end;{else:} end;{case n} end;{'2':} '3': with goods[n] do begin name1: write('Name of the thing: '); readln(name); if name=' ' then goto name1; for q:=1 to length(name) do for o:=1 to 10 do if name[q]=x[o] then goto name1; append(f1); write(f1,name,' '); model1: write('Model: '); readln(model); if model=' ' then goto model1; append(f1); write(f1,model,' '); giver1: write('Giver of the thing: '); readln(giver); if giver=' ' then goto giver1; for q:=1 to length(giver) do for o:=1 to 10 do if giver[q]=x[o] then goto giver1; append(f1); write(f1,giver,' '); year1: write('Year of the car(0 - if there is no): '); readln(year); if(year=' ') then goto year1; append(f1); write(f1,year,' '); colour1: write('Colour of the car(0 - if there is no): '); readln(colour); if (colour=' ')or(length(colour)>9) then goto colour1; append(f1); write(f1,colour,' '); processor1: write('Type of the processor(0 - if there is no): '); readln(processor); if (processor=' ')or(length(processor)>11) then goto processor1; append(f1); write(f1,processor,' '); memory1: write('Type of the memory(0 - if there is no): '); readln(memory); if (memory=' ')or(length(memory)>12) then goto memory1; for q:=1 to length(memory) do for o:=1 to 26 do if memory[q]=w[o] then goto memory1; append(f1); writeln(f1,memory,' '); close(f1); n:=n+1; goto start; end;{'3':} '4': begin write('Enter name of the thing: '); readln(a); i:=1;reset(f1); while not eof(f1) do begin readln(f1,r[i]); i:=i+1; end;{while} d:=i-1; i:=1; flag:=false; rewrite(f1); while i<=d do begin if copy(r[i],1,pos(' ',r[i])-1)<>a then begin append(f1); writeln(f1,r[i]); end{if } else begin flag:=true; n:=n-1; end;{else} i:=i+1; end;{while} if not flag then writeln('There is no such thing in data base!'); goto start; end;{'4': } '5': halt; else begin clrscr; writeln('You pressed wrong key! Try again.'); goto start; end;{else} end;{case c} readln; end.