SPrograMMer: и как можно решить проблему с head и new. И вообще как разместить запись в памяти частями???
Fedor: значит код моей базы данных такой:
Код | uses crt; type base=record name:string; processor:string; interf:string; system_bus_clockrate:string; max_processor:string; memory_type:string; ATA:string; USB:string; AGP:string; end; type point=^part; part=record data:base; next:point; end; const n=6;x=30;y=10;number=9; normal=$17; selected=$60; var head,p,p1:point; menu:array [1..number] of string; a:array [1..n] of string; i,item,q,l:byte; ch:char; f:file of base; path:string; x1,y1:word; ================ procedure file_new(var path:string); (определяем имя загружаемого файла) var j:byte;nam:string; begin clrscr; path:=''; gotoxy(x,y); write('Input the name of a new file: '); read(nam); readln; path:=nam; end;
procedure printing(l:byte); (печатаем данные из файла) var i,j:byte; x2,y2:word; begin p1:=head; i:=0; repeat x2:=34+i*l+1; y2:=2; gotoxy(x2,y2); for j:=1 to l do write(' '); gotoxy(x2,y2); write (p1^.data.name); gotoxy(x2,y2+2); for j:=1 to l do write(' '); gotoxy(x2,y2+2); write (p1^.data.processor); gotoxy(x2,y2+4); for j:=1 to l do write(' '); gotoxy(x2,y2+4); write (p1^.data.interf); gotoxy(x2,y2+6); for j:=1 to l do write(' '); gotoxy(x2,y2+6); write (p1^.data.system_bus_clockrate); gotoxy(x2,y2+8); for j:=1 to l do write(' '); gotoxy(x2,y2+8); write (p1^.data.max_processor); gotoxy(x2,y2+10); for j:=1 to l do write(' '); gotoxy(x2,y2+10); write (p1^.data.memory_type); gotoxy(x2,y2+12); for j:=1 to l do write(' '); gotoxy(x2,y2+12); write (p1^.data.ATA); gotoxy(x2,y2+14); for j:=1 to l do write(' '); gotoxy(x2,y2+14); write (p1^.data.USB); gotoxy(x2,y2+14); for j:=1 to l do write(' '); gotoxy(x2,y2+14); write (p1^.data.AGP); p1:=p1^.next; inc(i); until p1=nil; end;
procedure loading(i:byte; chipset:base); (загружаем данные в оперативную память) var j:byte; begin while i<=q do if i=1 then begin new(p); p^.data:=chipset; if i=1 then begin p^.next:=head;head:=p; end else begin p1:=head; for j:=2 to i-1 do p1:=p1^.next; p^.next:=p1^.next; p1^.next:=p; end; {new(p); p^.data:=chipset; writeln(p^.data.name); readkey; p^.next:=head; head:=p; {writeln(head^.data.name); end else begin p1:=head; for j:=1 to i-1 do p1:=p1^.next; p1^.next:=p; p:=p1;} end; readkey; end;
procedure reading (x,y:word);(читаем данные из файла) var name:string; i,j,k:byte; begin file_new(path); assign(f,path); {$I-} reset(f); {$I+} if IOResult<>0 then begin gotoxy(x,y+1); write('File is not found.'); end else begin i:=0; while not eof(f) do begin inc(i); read(f,chipset); if q<>0 then begin for i:=1 to q do begin { and (i<=n) and (head<>nil) then } if i=1 then begin p:=head^.next; dispose(head); head:=p; end else begin p:=head; for k:=2 to i-1 do p:=p^.next; p1:=p^.next; p^.next:=p1^.next; dispose(p1); end; end;end;
loading(i,chipset); end; gotoxy(x,y+1); write('The loading has passed aptly.'); end; gotoxy(x,y+2); write('Press <Enter>'); readkey; end; ================================(запись данных в файл - первоначальное создание БД) procedure inputchar(var mas:string); var h:char; begin h:=readkey; mas:=''; while (h<>#13) do begin mas:=mas+h; write(h); h:=readkey; end; end;
procedure kursor(item:byte);forward;
procedure create(x:byte); var j,k:byte; mas:string; c:char; begin file_new(path); assign (f,path); rewrite (f); q:=0; repeat inc(q); table(number,31,x,true); for i:=1 to number do begin gotoxy(x,y+i-1); write(menu[i]); end; gotoxy (32,6); write('Database creating'); for i:=1 to number do begin if i>1 then begin gotoxy(x+31,y+i-2); textbackground(blue); for j:=1 to 14 do write(' '); gotoxy(x+31,y+i-2); write (mas); end; gotoxy(x+31,y+i-1); textbackground(green); for j:=1 to 14 do write(' '); gotoxy(x+31,y+i-1); inputchar(mas); case i of 1:chipset.name:=mas; 2:chipset.processor:=mas; 3:chipset.interf:=mas; 4:chipset.system_bus_clockrate:=mas; 5:chipset.max_processor:=mas; 6:chipset.memory_type:=mas; 7:chipset.ATA:=mas; 8:chipset.USB:=mas; 9:chipset.AGP:=mas; end; if i=number then begin gotoxy(x+31,y+i-1); textbackground(blue); for j:=1 to 14 do write(' '); gotoxy(x+31,y+i-1); write (mas); end; end; gotoxy(30,20); write('One more record (y/n)? '); c:=readkey; write(f,chipset); until c=#110; close(f); end;
|
ну там еще несколько процедур: создание таблиц, управление курсором и т.д.
|