Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.01.13;
Скачать: CL | DM;

Вниз

PostGluk   Найти похожие ветки 

 
Fuinadan ©   (2002-12-18 18:11) [0]

Для Alx2
unit CBaseClass;
interface

const DBlockSize=512;
DBlockCount=12;

type TBirthDay = string[10];

TRecType = record
Mark: shortstring;
Model: shortstring;
Producer: shortstring;
BirthDay: TBirthDay;
BestBefore: Word;
Price: Currency;
Diagon: word;
Used: Boolean;
end;
const EmptyRec: TRecType=(Mark: "";Model: ""; Producer: ""; BirthDay: ""; BestBefore: 0;
Price: 0;Diagon: 0; Used: false);
type Plist=^list;
list = record
pos: LongInt;
R: TRecType;
pNext: plist;
pPrev: plist;
end;
TIDT = class
public
FileName: String;
FOpened: Boolean;
BlockSize, BlockCount: Word;
constructor Create;
function ReadOne(var pos_: LongInt): TRecType;
procedure EraseOne(R: TRecType);
procedure AddOne(R: TRecType);
procedure FindOne(R: TRecType; head: Plist);
procedure EditOne(R,R1: TRecType);
procedure CreateFile();
procedure OpenFile();
procedure CloseFile();
procedure EraseFile();
function Hash( HModel: shortstring ): Word;
private
F: File of TRecType;
function Move(var R: TRecType): Boolean;
end;

implementation
uses SysUtils;

constructor TIDT.Create;
begin
BlockSize:=DBlockSize;
BlockCount:=DBlockCount;
FOpened:=false;
FileName:="";
end;

function TIDT.ReadOne(var pos_: LongInt): TRecType;
var R: TRecType;
begin
R:=EmptyRec; //перебор
if FOpened then begin
if pos_ > -1 then begin
if pos_ < FileSize(F) then begin
seek(F, pos_); read(F, R); Inc(pos_);
end
else begin
pos_:=-1
end
end
end
else begin pos_:=-2 end;
ReadOne:=R;
end;


procedure TIDT.CreateFile();
var INI: TextFile;
S: String;
i: LongInt;
begin if FOpened then CloseFile(); //In case of fire...
S := FileName; SetLength(S,Length(S)-3); S:=S+"ini";
AssignFile(F, FileName); Rewrite(F);
AssignFile(INI,S); Rewrite(INI);
Writeln(INI,BlockSize); Writeln(INI,BlockCount);
System.CloseFile(INI);
for i:=1 to BlockSize*BlockCount do write(F, EmptyRec);
FOpened:=true;
end;

procedure TIDT.OpenFile();
var INI: TextFile;
S: String;
begin
if FOpened then CloseFile(); // на всякий пожврный...
S := FileName; SetLength(S,Length(S)-3); S:=S+"ini";
AssignFile(F, FileName); Reset(F);
AssignFile(INI,S); Reset(INI);
Readln (INI, BlockSize);
Readln (INI, BlockCount);
System.CloseFile(INI);
FOpened:=true;
end;


 
Fuinadan ©   (2002-12-18 18:20) [1]

Да,все молчат...А мне курсач сдавать, м/ду прочим...:((


 
FreeLancer ©   (2002-12-18 18:23) [2]


> Fuinadan © (18.12.02 18:20)
> Да,все молчат...А мне курсач сдавать, м/ду прочим...:((

Счастливый...
А нам домой пора :-)



Страницы: 1 вся ветка

Текущий архив: 2003.01.13;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.015 c
1-37204
TCrash
2002-12-30 12:53
2003.01.13
Отловить закрытие формы


4-37452
Славик@Майл2к.ру
2002-11-24 07:38
2003.01.13
Перехват сообщения об ошибке и ...........


1-37083
alvin
2003-01-03 10:24
2003.01.13
TreeView


14-37307
sancho
2002-12-22 18:25
2003.01.13
BUTTON


3-36926
Дот
2002-12-17 16:42
2003.01.13
Table corrupt other than header