SlideShare a Scribd company logo
1 of 16
procedure TfrmFileMngm.FormCreate(Sender: TObject);
begin
sgCars.Cells[0,0] := 'Марка';
sgCars.Cells[1,0] := 'V';
sgCars.Cells[2,0] := 'S';
sgErr.Cells[0,0] := 'Строка';
sgErr.Cells[1,0] := 'Ошибка';
Cars := TCarsMngm.Create;
end;
procedure TfrmFileMngm.btnCleanClick(Sender: TObject);
begin
lblErr.Visible := false;
sgErr.Visible := false;
btnClean.Visible := false;
end;
procedure TfrmFileMngm.btnConvClick(Sender: TObject);
begin
if odCars.Execute then
if not Cars.Convert(odCars.FileName, sgErr) then
begin
lblErr.Visible := true;
sgErr.Visible := true;
btnClean.Visible := true;
end;
end;
procedure TfrmFileMngm.btnLoadClick(Sender: TObject);
begin
if odCars.Execute then
Cars.Load(odCars.FileName, sgCars);
end;
type
TCar = record
Mark : string[25];
V : single;
S : integer;
end;
TCars = array of TCar;
TCarsMngm = class
fCarsTxt : text;
bCarsTxt : string;
fCars : file of TCar;
bCars : TCar;
Cars : TCars;
function ConvertRec : integer;
function Convert (_fIn : string; var _Err : TStringGrid) : boolean;
procedure Load(_fIn : string; var _Cars : TStringGrid);
end;
function TCarsMngm.Convert(_fIn : string; var _Err : TStringGrid) : boolean;
var
Cnv : integer;
Res : boolean;
S:string;
begin
Cnv := 0;
AssignFile(fCarsTxt, _fIn);
reset(fCarsTxt);
S:=copy(_fIn, 1, length(_fIn) - 7) + 'dat';
AssignFile(fCars, S);
rewrite(fCars);
Res := true;
while not eof(fCarsTxt) do
begin
readln(fCarsTxt, bCarsTxt);
Cnv := ConvertRec;
Res := Res and (Cnv = 0);
case Cnv of
0 : write(fCars, bCars);
1 : begin
_Err.Cells[ 0, _Err.RowCount ] := bCarsTxt;
_Err.Cells[ 1, _Err.RowCount ] := 'Ошибка V';
_Err.RowCount := _Err.RowCount +1;
end;
2 : begin
_Err.Cells[ 0, _Err.RowCount ] := bCarsTxt;
_Err.Cells[ 1, _Err.RowCount ] := 'Ошибка S';
_Err.RowCount := _Err.RowCount +1;
end;
3 : begin
_Err.Cells[ 0, _Err.RowCount ] := bCarsTxt;
_Err.Cells[ 1, _Err.RowCount ] := ‘Ошибка формата';
_Err.RowCount := _Err.RowCount +1;
end;
end; {case}
end; {while}
close(fCars);
close(fCarsTxt);
Convert := Res;
end;
function TCarsMngm.ConvertRec : integer;
var
tmp : string;
begin
tmp := bCarsTxt;
if Pos('' , tmp) > 0 then
begin
bCars.Mark := copy(tmp, 1, Pos('' , tmp) - 1);
delete(tmp, 1, Pos('' , tmp));
if Pos('' , tmp) > 0 then
begin
if TryStrToFloat(copy(tmp, 1, Pos('' , tmp) - 1), bCars.V) then
begin
delete(tmp, 1, Pos('' , tmp));
if TryStrToInt(tmp, bCars.S) then
ConvertRec := 0
else
ConvertRec := 2;
end
else
ConvertRec := 1;
end
else
ConvertRec := 3;
end
else
ConvertRec := 3;
end;
procedure TCarsMngm.Load(_fIn : string; var _Cars: TStringGrid);
var
i : integer;
begin
AssignFile(fCars, _fIn);
reset(fCars);
_Cars.RowCount := FileSize(fCars) + 1;
i:=0;
while not eof(fCars) do
begin
read(fCars, bCars);
i := i+1;
_Cars.Cells[0,i] := bCars.Mark;
_Cars.Cells[1,i] := FloatToStr(bCars.V);
_Cars.Cells[2,i] := IntToStr(bCars.S);
end;
close(fCars);
end;
type
TProductComposition=record
Product,
{ изделие-узел}
Element : string[25];
{ узел-деталь }
Quantity : integer;
{ количество }
end;
TCorrProductComposition=class
fProductComposition:file of TProductComposition;
bProductComposition:TProductComposition;
fProof:file of TProductComposition;
bProof:TProductComposition;
fCorr:file of TProductComposition;
bCorr:TProductComposition;
procedure ConvProdComp;
procedure ConvProof;
procedure Correct;
procedure ShowCorr(var _Res:TStringGrid;_f:integer);
function Compare:integer;
end;
function TCorrProductComposition.Compare: integer;
begin
if bProductComposition.Product < bProof.Product then
Compare := 0
else
if bProductComposition.Product = bProof.Product then
if bProductComposition.Element < bProof.Element then
Compare := 0
else
if bProductComposition.Element = bProof.Element then
Compare := 1
else
Compare := 2
else
Compare :=2 ;
end;
function TMerge.Compare(_Scoop:boolean): integer;
var
KeyBucket, KeyFile: shortstring;
begin
with Bucket do
KeyBucket:=Format('%2d%100s%2d',[Grade,Theme,ComplexityLevel]);
if _Scoop then
with bStudents do
KeyFile:=Format('%2d%100s%2d',[Grade,Theme,ComplexityLevel])
else
with bProblemPool do
KeyFile:=Format('%2d%100s%2d',
[Grade,Theme,Problem.ComplexityLevel]);
if KeyBucket < KeyFile then
Compare:=0
else
if KeyBucket = KeyFile then
Compare:=1
else
Compare:=2;
end;
TfrmFileMngm = class(TForm)
odCars: TOpenDialog;
sgCars: TStringGrid;
sgErr: TStringGrid;
lblCars: TLabel;
lblErr: TLabel;
btnConv: TButton;
btnClean: TButton;
sdCars: TSaveDialog;
btnLoad: TButton;
edtSI: TLabeledEdit;
lblRes: TLabel;
btnSearch: TButton;
btnCreateH: TButton;
procedure btnSearchClick(Sender: TObject);
procedure btnCreateHClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnConvClick(Sender: TObject);
procedure btnCleanClick(Sender: TObject);
procedure btnLoadClick(Sender: TObject);
end;
function TCarsMngm.Hash(_S:string):integer;
var
tmp, e, i: integer;
begin
tmp := 0;
e := 1;
for i := 1 to length(_S) do
begin
tmp := tmp + ord(_S [ i ]) * e;
e := e * b;
end;
Hash := tmp mod H;
end;
procedure TCarsMngm.HCreate(_fIn: string);
var
i: integer;
begin
AssignFile(fCars, _fIn);
reset(fCars);
AssignFile(fHash, copy(_fIn, 1, pos('.', _fIn)) + 'hsh');
rewrite(fHash);
bCars.Mark := '';
bCars.V := 0;
bCars.S := 0;
for i := 1 to H do
write(fHash, bCars);
reset(fHash);
while not eof(fCars) do
begin
read(fCars, bCars);
seek(fHash, Hash(bCars.Mark));
write(fHash, bCars);
end;
close(fHash);
end;
function TCarsMngm.HSearch(_fIn: string; _SI: string):string;
begin
AssignFile(fHash, _fIn);
reset(fHash);
seek(fHash, Hash(_SI));
read(fHash, bCars);
HSearch := FloatToStrF(bCars.V, ffFixed, 1,3) + ' ' + intToStr(bCars.S);
close(fHash);
end;

More Related Content

What's hot (12)

Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Snake.c
Snake.cSnake.c
Snake.c
 
Circular queue
Circular queueCircular queue
Circular queue
 
Class & sub class
Class & sub classClass & sub class
Class & sub class
 
Script
ScriptScript
Script
 
week-23x
week-23xweek-23x
week-23x
 
Program to illustrate Switch, Goto and Exit statements.
Program to illustrate Switch, Goto and  Exit statements.Program to illustrate Switch, Goto and  Exit statements.
Program to illustrate Switch, Goto and Exit statements.
 
C++11 move semantics
C++11 move semanticsC++11 move semantics
C++11 move semantics
 
C++ loop
C++ loop C++ loop
C++ loop
 
Presentacion vim
Presentacion vimPresentacion vim
Presentacion vim
 
Promise of an API
Promise of an APIPromise of an API
Promise of an API
 
Golang Channels
Golang ChannelsGolang Channels
Golang Channels
 

Similar to File mngm

The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain EnterpriseClarkTony
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil Witecki
 
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdfProject 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdfaminbijal86
 
Help with Starting out with visual basic 7th edition chapter 6 Progr.pdf
Help with Starting out with visual basic 7th edition chapter 6 Progr.pdfHelp with Starting out with visual basic 7th edition chapter 6 Progr.pdf
Help with Starting out with visual basic 7th edition chapter 6 Progr.pdfezycolours78
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdfMOJO89
 

Similar to File mngm (7)

The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain Enterprise
 
11 tm
11 tm11 tm
11 tm
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, code
 
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdfProject 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
 
Presentation1
Presentation1Presentation1
Presentation1
 
Help with Starting out with visual basic 7th edition chapter 6 Progr.pdf
Help with Starting out with visual basic 7th edition chapter 6 Progr.pdfHelp with Starting out with visual basic 7th edition chapter 6 Progr.pdf
Help with Starting out with visual basic 7th edition chapter 6 Progr.pdf
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdf
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

File mngm

  • 1.
  • 2.
  • 3. procedure TfrmFileMngm.FormCreate(Sender: TObject); begin sgCars.Cells[0,0] := 'Марка'; sgCars.Cells[1,0] := 'V'; sgCars.Cells[2,0] := 'S'; sgErr.Cells[0,0] := 'Строка'; sgErr.Cells[1,0] := 'Ошибка'; Cars := TCarsMngm.Create; end; procedure TfrmFileMngm.btnCleanClick(Sender: TObject); begin lblErr.Visible := false; sgErr.Visible := false; btnClean.Visible := false; end;
  • 4. procedure TfrmFileMngm.btnConvClick(Sender: TObject); begin if odCars.Execute then if not Cars.Convert(odCars.FileName, sgErr) then begin lblErr.Visible := true; sgErr.Visible := true; btnClean.Visible := true; end; end; procedure TfrmFileMngm.btnLoadClick(Sender: TObject); begin if odCars.Execute then Cars.Load(odCars.FileName, sgCars); end;
  • 5. type TCar = record Mark : string[25]; V : single; S : integer; end; TCars = array of TCar; TCarsMngm = class fCarsTxt : text; bCarsTxt : string; fCars : file of TCar; bCars : TCar; Cars : TCars; function ConvertRec : integer; function Convert (_fIn : string; var _Err : TStringGrid) : boolean; procedure Load(_fIn : string; var _Cars : TStringGrid); end;
  • 6. function TCarsMngm.Convert(_fIn : string; var _Err : TStringGrid) : boolean; var Cnv : integer; Res : boolean; S:string; begin Cnv := 0; AssignFile(fCarsTxt, _fIn); reset(fCarsTxt); S:=copy(_fIn, 1, length(_fIn) - 7) + 'dat'; AssignFile(fCars, S); rewrite(fCars); Res := true; while not eof(fCarsTxt) do begin readln(fCarsTxt, bCarsTxt); Cnv := ConvertRec; Res := Res and (Cnv = 0);
  • 7. case Cnv of 0 : write(fCars, bCars); 1 : begin _Err.Cells[ 0, _Err.RowCount ] := bCarsTxt; _Err.Cells[ 1, _Err.RowCount ] := 'Ошибка V'; _Err.RowCount := _Err.RowCount +1; end; 2 : begin _Err.Cells[ 0, _Err.RowCount ] := bCarsTxt; _Err.Cells[ 1, _Err.RowCount ] := 'Ошибка S'; _Err.RowCount := _Err.RowCount +1; end; 3 : begin _Err.Cells[ 0, _Err.RowCount ] := bCarsTxt; _Err.Cells[ 1, _Err.RowCount ] := ‘Ошибка формата'; _Err.RowCount := _Err.RowCount +1; end; end; {case} end; {while} close(fCars); close(fCarsTxt); Convert := Res; end;
  • 8. function TCarsMngm.ConvertRec : integer; var tmp : string; begin tmp := bCarsTxt; if Pos('' , tmp) > 0 then begin bCars.Mark := copy(tmp, 1, Pos('' , tmp) - 1); delete(tmp, 1, Pos('' , tmp)); if Pos('' , tmp) > 0 then begin if TryStrToFloat(copy(tmp, 1, Pos('' , tmp) - 1), bCars.V) then begin delete(tmp, 1, Pos('' , tmp)); if TryStrToInt(tmp, bCars.S) then ConvertRec := 0 else ConvertRec := 2; end else ConvertRec := 1; end else ConvertRec := 3; end else ConvertRec := 3; end;
  • 9. procedure TCarsMngm.Load(_fIn : string; var _Cars: TStringGrid); var i : integer; begin AssignFile(fCars, _fIn); reset(fCars); _Cars.RowCount := FileSize(fCars) + 1; i:=0; while not eof(fCars) do begin read(fCars, bCars); i := i+1; _Cars.Cells[0,i] := bCars.Mark; _Cars.Cells[1,i] := FloatToStr(bCars.V); _Cars.Cells[2,i] := IntToStr(bCars.S); end; close(fCars); end;
  • 10. type TProductComposition=record Product, { изделие-узел} Element : string[25]; { узел-деталь } Quantity : integer; { количество } end; TCorrProductComposition=class fProductComposition:file of TProductComposition; bProductComposition:TProductComposition; fProof:file of TProductComposition; bProof:TProductComposition; fCorr:file of TProductComposition; bCorr:TProductComposition; procedure ConvProdComp; procedure ConvProof; procedure Correct; procedure ShowCorr(var _Res:TStringGrid;_f:integer); function Compare:integer; end;
  • 11. function TCorrProductComposition.Compare: integer; begin if bProductComposition.Product < bProof.Product then Compare := 0 else if bProductComposition.Product = bProof.Product then if bProductComposition.Element < bProof.Element then Compare := 0 else if bProductComposition.Element = bProof.Element then Compare := 1 else Compare := 2 else Compare :=2 ; end;
  • 12. function TMerge.Compare(_Scoop:boolean): integer; var KeyBucket, KeyFile: shortstring; begin with Bucket do KeyBucket:=Format('%2d%100s%2d',[Grade,Theme,ComplexityLevel]); if _Scoop then with bStudents do KeyFile:=Format('%2d%100s%2d',[Grade,Theme,ComplexityLevel]) else with bProblemPool do KeyFile:=Format('%2d%100s%2d', [Grade,Theme,Problem.ComplexityLevel]); if KeyBucket < KeyFile then Compare:=0 else if KeyBucket = KeyFile then Compare:=1 else Compare:=2; end;
  • 13. TfrmFileMngm = class(TForm) odCars: TOpenDialog; sgCars: TStringGrid; sgErr: TStringGrid; lblCars: TLabel; lblErr: TLabel; btnConv: TButton; btnClean: TButton; sdCars: TSaveDialog; btnLoad: TButton; edtSI: TLabeledEdit; lblRes: TLabel; btnSearch: TButton; btnCreateH: TButton; procedure btnSearchClick(Sender: TObject); procedure btnCreateHClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure btnConvClick(Sender: TObject); procedure btnCleanClick(Sender: TObject); procedure btnLoadClick(Sender: TObject); end;
  • 14. function TCarsMngm.Hash(_S:string):integer; var tmp, e, i: integer; begin tmp := 0; e := 1; for i := 1 to length(_S) do begin tmp := tmp + ord(_S [ i ]) * e; e := e * b; end; Hash := tmp mod H; end;
  • 15. procedure TCarsMngm.HCreate(_fIn: string); var i: integer; begin AssignFile(fCars, _fIn); reset(fCars); AssignFile(fHash, copy(_fIn, 1, pos('.', _fIn)) + 'hsh'); rewrite(fHash); bCars.Mark := ''; bCars.V := 0; bCars.S := 0; for i := 1 to H do write(fHash, bCars); reset(fHash); while not eof(fCars) do begin read(fCars, bCars); seek(fHash, Hash(bCars.Mark)); write(fHash, bCars); end; close(fHash); end;
  • 16. function TCarsMngm.HSearch(_fIn: string; _SI: string):string; begin AssignFile(fHash, _fIn); reset(fHash); seek(fHash, Hash(_SI)); read(fHash, bCars); HSearch := FloatToStrF(bCars.V, ffFixed, 1,3) + ' ' + intToStr(bCars.S); close(fHash); end;