. , , ,

,,,

, —

1.

, . :

*

* ( )

* , :

*

*

*

*

*

2.

2.1.

.

. , , , .

. . . , . , , .

2.2.

( ) ( )

12 23 34 4100 5200 6400 70,5 81 92 101 112 124 1310 1413 1515 16171819 1- 20 2- 21222324 1- 25 2- 26272829

1941,4,7,282043,5,8,282145,9,11,1722521,3,4,12,1523222,282431,7,282533,8,2826322,16,2927322,18,29

2.3.

, .

windows- - , . , , : , : , "" . , , . (Alt + ). , CulinaryMiracles : , , . , , .

, . . . -, , , -, , , -, , , , . : / / - "(", / / - "(" "OK". "".

"Culinary Miracles" , , , , . , () , .

, , , -: , , .. , Windows.

2.4.

2.4.1.

3 . , : (), (), . , .

1. . . (.. ) , , . . .. , .

2. . . , , .

3. . , , , .

2.4.2.

: .

, .

.

. ࠠ . , (), , , .

. .

, , , .

Direct.

2.4.3.

: .

. .

. ( ) , . , , , .

. .

. .

Inv.

2.5.

3.

3.1.

Delphi 4 ( dpr) ( pas), Object Pascal. , Object Pascal . Delphi, .

Delphi 4 CulinaryMiracles : Culinary.pas, About.pas, Help.pas.

3.2.

Object Pascal - - , - , . , , .

3.3.

1procedure FormActivate , Base.dat2.

2procedure Timer1Timer 3. 3procedure N6Click 4.

4procedure N2Click 5.

5Procedure SpeedButton3Click , 6.

6Procedure SpeedButton1Click 7.

7Procedure SpeedButton8Click , 8.

Procedure SpeedButton2Click , 9.

procedure N7Click

procedure BitBtn1Click " "11.

Procedure BitBtn3Click " "12.

Procedure BitBtn5Click , , 13.

Procedure BitBtn6Click , 14. Procedure Timer2Timer !15.

Procedure LoadBase 16.

procedure SaveBase 17.

Procedure SpeedButton6Click , 18.

Procedure SpeedButton7Click , 19.

procedure ListBox1Click " "20.

Procedure SpeedButton4Click , 21.

Procedure SpeedButton10Click , 22.

Procedure RadioGroup1Click 23.

procedure AddSimpleFact 24.

Procedure SpeedButton9Click , AddSimpleFact25.

Procedure SpeedButton11Click , 26. Procedure AddComplexFact 27.

procedure DeleteFact 28.

Procedure SpeedButton5Click 29.

Procedure BitBtn2Click " "30.

procedure BitBtn4Click " "31.

procedure N5Click , 32.

procedure N4Click ,

4.

1. .., .., ... .- .: , 1985.

2. .. Delphi4, . - .: "",1999.

3. .. , .. , .. . , . - .: , 1995.

4. , . Delphi 4 - , BHV, 1999.

5.

5.1.

unit Culinary;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

ExtCtrls, StdCtrls, jpeg, Menus, Buttons;

type

TForm1 = class(TForm)

Image1: TImage;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Timer1: TTimer;

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

SpeedButton1: TSpeedButton;

SpeedButton2: TSpeedButton;

SpeedButton3: TSpeedButton;

ListBox1: TListBox;

ListBox2: TListBox;

Label4: TLabel;

Label5: TLabel;

Bevel1: TBevel;

Bevel2: TBevel;

SpeedButton4: TSpeedButton;

SpeedButton5: TSpeedButton;

SpeedButton6: TSpeedButton;

SpeedButton7: TSpeedButton;

SpeedButton8: TSpeedButton;

Bevel3: TBevel;

ListBox4: TListBox;

ListBox5: TListBox;

ListBox6: TListBox;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

BitBtn3: TBitBtn;

BitBtn4: TBitBtn;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

Bevel4: TBevel;

Bevel5: TBevel;

N7: TMenuItem;

BitBtn5: TBitBtn;

ComboBox1: TComboBox;

ComboBox2: TComboBox;

Label11: TLabel;

Label12: TLabel;

BitBtn6: TBitBtn;

Label13: TLabel;

Timer2: TTimer;

ListBox3: TListBox;

OpenDialog1: TOpenDialog;

SaveDialog1: TSaveDialog;

Bevel6: TBevel;

Bevel7: TBevel;

Label6: TLabel;

ComboBox3: TComboBox;

Edit1: TEdit;

RadioGroup1: TRadioGroup;

Panel1: TPanel;

SpeedButton9: TSpeedButton;

SpeedButton10: TSpeedButton;

Label14: TLabel;

Label15: TLabel;

SpeedButton11: TSpeedButton;

procedure FormActivate(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure N6Click(Sender: TObject);

procedure N2Click(Sender: TObject);

procedure SpeedButton3Click(Sender: TObject);

procedure SpeedButton1Click(Sender: TObject);

procedure SpeedButton8Click(Sender: TObject);

procedure SpeedButton2Click(Sender: TObject);

procedure N7Click(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);

procedure BitBtn5Click(Sender: TObject);

procedure BitBtn6Click(Sender: TObject);

procedure Timer2Timer(Sender: TObject);

procedure LoadBase;

procedure SaveBase;

procedure SpeedButton6Click(Sender: TObject);

procedure SpeedButton7Click(Sender: TObject);

procedure ListBox1Click(Sender: TObject);

procedure SpeedButton4Click(Sender: TObject);

procedure SpeedButton10Click(Sender: TObject);

procedure RadioGroup1Click(Sender: TObject);

procedure AddSimpleFact;

procedure SpeedButton9Click(Sender: TObject);

procedure SpeedButton11Click(Sender: TObject);

procedure AddComplexFact;

procedure DeleteFact;

procedure SpeedButton5Click(Sender: TObject);

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn4Click(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure N4Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

TFactFile = record {}

Number:integer; { }

Znach:string[40]; { }

Q:integer; { }

FactIn:array[1..10] of integer; { }

Zel:byte;{ }

end;

TKnow = Record { }

Number:integer; { }

Q:integer; { }

FactIn:array[1..10] of integer; { }

Zel:byte;

end;

TFact= record {}

Number:integer; { }

Znach:string[40]; { }

end;

TBase=Record

Fact:array[1..40] of integer;

Rule:array [1..40] of TKnow;

end;

TFF=file of TFactFile;

var

Form1: TForm1;

FF:TFF;

TermFact:array[1..50] of integer; { c }

NE,NK,NF,NF1,NFF,NR,KEND,Rez,NST,Num:integer;

Spis:array[1..30] of integer; { }

SpisF:array[1..30] of integer; { }

BaseKnow:TBase;

Knowledge:array[1..5] of integer; { }

VectFact:array[1..50] of TFact; { }

implementation

uses About, Help;

{$R *.DFM}

procedure TForm1.FormActivate(Sender: TObject);

var

Know:TKnow;

Fact:TFact; FactFile:TFactFile;

i,j:integer;

begin

NF:=0;NF1:=0;NK:=0;

AssignFile(FF,'Base.dat'); { }

Reset(FF);

NFF:=0;

While Not eof(FF) do

begin

Read(FF,FactFile);

NFF:=NFF+1;

VectFact[NFF].Number:=FactFile.Number;

VectFact[NFF].Znach:=FactFile.Znach;

ListBox1.Items.Add(VectFact[NFF].Znach);

ListBox3.Items.Add(VectFact[NFF].Znach);

if FactFile.Q>1 then

begin

NR:=NR+1;

BaseKnow.Rule[NR].Number:=FactFile.Number;

BaseKnow.Rule[NR].Zel:=FactFile.Zel;

ListBox5.Items.Add(FactFile.Znach);

BaseKnow.Rule[NR].Q:=FactFile.Q;

for i:=1 to BaseKnow.Rule[NR].Q do

BaseKnow.Rule[NR].FactIn[i]:=FactFile.FactIn[i];

end;

end;

closefile(FF);

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

label1.top:=label1.top-2;

label2.left:=label2.left+4;

label3.top:=label3.top+2;

if label2.left=100 then

timer1.Enabled:=false;

end;

procedure TForm1.N6Click(Sender: TObject);

begin

AboutBox.Show;

end;

procedure TForm1.N2Click(Sender: TObject);

begin

N1.Visible:=false;

N2.Visible:=false;

N3.Visible:=false;

N4.Visible:=false;

{N5.Visible:=false;

N6.Visible:=false;}

label1.Visible:=false;

label2.Visible:=false;

label3.Visible:=false;

form1.Height:=150;

form1.Width:=185;

form1.BorderStyle:=bsDialog;

form1.Position:=poScreenCenter;

speedbutton1.Visible:=true;

speedbutton2.Visible:=true;

speedbutton3.Visible:=true;

end;

procedure TForm1.SpeedButton3Click(Sender: TObject);

begin

close;

end;

procedure TForm1.SpeedButton1Click(Sender: TObject);

begin

form1.Height:=343;

form1.Width:=450;

form1.BorderStyle:=bsSingle;

form1.Position:=poScreenCenter;

speedbutton1.Visible:=false;

speedbutton2.Visible:=false;

speedbutton3.Visible:=false;

speedbutton4.Visible:=true;

speedbutton5.Visible:=true;

speedbutton6.Visible:=true;

speedbutton7.Visible:=true;

speedbutton8.Visible:=true;

listbox1.Visible:=true;

listbox2.Visible:=true;

bevel1.Visible:=true;

bevel2.Visible:=true;

bevel3.Visible:=true;

bevel3.Width:=430;

label4.Visible:=true;

label5.Visible:=true;

label6.Visible:=true;

end;

procedure TForm1.SpeedButton8Click(Sender: TObject);

begin

form1.Height:=150;

form1.Width:=185;

form1.BorderStyle:=bsDialog;

form1.Position:=poScreenCenter;

speedbutton1.Visible:=true;

speedbutton2.Visible:=true;

speedbutton3.Visible:=true;

speedbutton5.Visible:=false;

speedbutton6.Visible:=false;

speedbutton7.Visible:=false;

speedbutton8.Visible:=false;

listbox1.Visible:=false;

listbox2.Visible:=false;

bevel1.Visible:=false;

bevel2.Visible:=false;

bevel3.Visible:=false;

bevel3.Width:=481;

label4.Visible:=false;

label5.Visible:=false;

label6.Visible:=false;

panel1.Visible:=false;

edit1.Visible:=false;

combobox3.Visible:=false;

radiogroup1.Visible:=false;

speedbutton11.visible:=false;

end;

procedure TForm1.SpeedButton2Click(Sender: TObject);

begin

form1.Height:=343;

form1.Width:=503;

form1.BorderStyle:=bsSingle;

form1.Position:=poScreenCenter;

speedbutton1.Visible:=false;

speedbutton2.Visible:=false;

speedbutton3.Visible:=false;

BitBtn5.Visible:=true;

BitBtn6.Visible:=true;

bevel3.Visible:=true;

bevel4.Visible:=true;

bevel5.Visible:=true;

bevel6.Visible:=true;

bevel7.Visible:=true;

ListBox3.Visible:=true;

ListBox4.Visible:=true;

ListBox5.Visible:=true;

ListBox6.Visible:=true;

label7.Visible:=true;

label8.Visible:=true;

label9.Visible:=true;

label10.Visible:=true;

label11.Visible:=true;

label12.Visible:=true;

ComboBox1.Visible:=true;

ComboBox2.Visible:=true;

BitBtn1.Visible:=true;

BitBtn2.Visible:=true;

BitBtn3.Visible:=true;

BitBtn4.Visible:=true;

N7.Visible:=true;

end;

procedure TForm1.N7Click(Sender: TObject);

begin

form1.Height:=150;

form1.Width:=185;

form1.BorderStyle:=bsDialog;

form1.Position:=poScreenCenter;

speedbutton1.Visible:=true;

speedbutton2.Visible:=true;

speedbutton3.Visible:=true;

BitBtn5.Visible:=false;

BitBtn6.Visible:=false;

bevel3.Visible:=false;

bevel4.Visible:=false;

bevel5.Visible:=false;

bevel6.Visible:=false;

bevel7.Visible:=false;

ListBox3.Visible:=false;

ListBox4.Visible:=false;

ListBox5.Visible:=false;

ListBox6.Visible:=false;

label7.Visible:=false;

label8.Visible:=false;

label9.Visible:=false;

label10.Visible:=false;

BitBtn1.Visible:=false;

BitBtn2.Visible:=false;

BitBtn3.Visible:=false;

BitBtn4.Visible:=false;

N7.Visible:=false;

label11.Visible:=false;

label12.Visible:=false;

ComboBox1.Visible:=false;

ComboBox2.Visible:=false;

BitBtn6Click(Sender);

end;

procedure TForm1.BitBtn1Click(Sender: TObject);

var

rab:integer;

begin

rab:=ListBox3.itemindex;

listbox4.Items.Add(VectFact[rab+1].Znach);

NF1:=NF1+1;

SpisF[NF1]:=VectFact[rab+1].Number;

BaseKnow.Fact[NF1]:=VectFact[rab+1].Number;

NF:=NF1;

end;

procedure TForm1.BitBtn3Click(Sender: TObject);

var rab,i,j:integer;

begin

rab:=ListBox5.itemindex;

for i:=1 to NFF do

if BaseKnow.Rule[rab+1].Number=VectFact[i].Number then

begin

listbox6.Items.Add(VectFact[i].Znach);

NK:=NK+1;

Knowledge[NK]:=VectFact[i].Number;

end;

end;

Procedure Direct;

var

KIZ,NS,KA,k,i,l,j:integer;

begin

{ }

KEnd:=0;KIZ:=0;NS:=0;

While ((KEnd=0) and (KIZ=0)) do

begin

{ , }

{ }

{ }

KIZ:=1;

i:=1;

While (i<=NR) and (Kend=0) do

begin

{ }

{ }

KA:=0; {: ?}

k:=1;

While ((KA=0) and (K<=NF)) do

begin

if BaseKnow.Rule[i].Number=BaseKnow.Fact[k] then

KA:=1; { }

k:=k+1;

end;

{: ?}

j:=1;

While ((j<=BaseKnow.Rule[i].Q) and (KA=0)) do

begin

{ }

KA:=1; k:=1;

While (k<=NF) and (KA=1) do

begin

{ }

{ }

if BaseKnow.Rule[i].FactIn[j]=BaseKnow.Fact[k] then

KA:=0;

k:=k+1;

end;

{ =1, ,}

{ }

j:=j+1;

end;

if KA=0 then

begin

{ , }

{ , }

NF:=NF+1;

BaseKnow.Fact[NF]:=BaseKnow.Rule[i].Number;

KIZ:=0;

{: }

{}

if BaseKnow.Rule[i].Zel=1 then

begin

KEND:=1;

Rez:=BaseKnow.Rule[i].Number;

end;

end;

i:=i+1;

end;

{ }

{ }

end;

end;

Procedure Inv;

var

KVPC,KVPF,AnFact,NS1,Rab,FindFactAn:integer;

L,NS,i,j,k,KA:integer;

begin

{ }

KEnd:=0; L:=1; NST:=0;

While (L<=NK) do

begin

{ }

{, }

{ -. }

KEND:=0;

Nst:=Nst+1;

Spis[Nst]:=Knowledge[l];

While (Kend=0)do

begin

FindFactAn:=0;

j:=0;

While (FindFactAn=0)and( j<=NST) do { }

begin

for k:=1 to NR do

if BaseKnow.Rule[k].Number=Spis[j]

then

begin

FindFactAn:=1; {, }

AnFact:=Spis[j]; { }

for i:=j to Nst-1 do

Spis[i]:=Spis[i+1];

Nst:=Nst-1;

end;

j:=j+1;

end;

if FindFactAn=0 then

KEnd:=1 { , }

else

begin

i:=1;

While (I<=NR) do

begin

{ - }

{ }

if AnFact=BaseKnow.Rule[i].Number then

begin

{ }

for j:=1 to BaseKnow.Rule[i].Q do

begin

NST:=NST+1;

Spis[Nst]:=BaseKnow.Rule[i].FactIn[j];

end;

end;{ }

i:=i+1;

end;{While }

end;

end;

l:=l+1;

end;{ }

if NST=NK then KEND:=0 else KEND:=1;

{ }

end;

procedure TForm1.BitBtn5Click(Sender: TObject); { }

var

i,j,k,KA,l:integer;

begin

BitBtn5.enabled:=false;

if (NF1<>0) and (NK=0) then { , }

begin

Direct;

if Kend<>0 then

begin

for i:=1 to NFF do

if VectFact[i].Number=Rez then

ListBox6.Items.Add(VectFact[i].Znach);

Label10.Caption:=' :';

Label10.Font.Color:=clnavy;

end

else

Application.MessageBox(' !','!',mb_iconwarning);

end;

if (NF1=0) and (NK<>0) then { , }

begin

Inv;

if KEnd<>0 then

begin

for i:=1 to NST do

for j:=1 to NFF do

if Spis[i]=VectFact[j].Number then

ListBox4.Items.Add(VectFact[j].Znach);

Label8.Caption:=' :';

Label8.Font.Color:=clnavy;

end;

end;

if (NK<>0) and (NF1<>0) then { }

begin

k:=1;

While (k<=NR) do

begin { }

i:=1; { }

KA:=0;

While (i<=NF1)and (KA=0) do

begin

if BaseKnow.Rule[k].Number=SpisF[i] then

begin

for j:=i to NF1-1 do

SpisF[j]:=SpisF[j+1];

NF1:=NF1-1;

KA:=1;

end;

i:=i+1;

end;

if KA=1 then

begin

for i:=1 to BaseKnow.Rule[k].Q do

begin

NF1:=NF1+1;

SpisF[NF1]:=BaseKnow.Rule[k].FactIn[i];

end;

k:=0;

end;

k:=k+1;

end;

INV;

i:=1;

While i<=NF1 do {, }

begin { }

KA:=0;

j:=1;

While (j<=NST) and (KA=0) do

begin

if SpisF[i]=Spis[j] then

Ka:=1;

j:=j+1;

end;

if KA=1 then

begin

for k:=i to NF1-1 do

SpisF[k]:=SpisF[k+1];

i:=i-1;

NF1:=NF1-1;

for l:=j-1 to NST-1 do

Spis[l]:=Spis[l+1];

NST:=Nst-1;

end;

i:=i+1;

end;

if (Nst=0)and (NF1=0) then

Timer2.Enabled:=true else

begin

KA:=0;

for i:=1 to NST do

for j:=1 to NFF do

begin

if (Spis[i]=VectFact[j].Number) and (KA=0) then

begin

combobox2.Text:=VectFact[j].Znach;

KA:=1;

end;

if (Spis[i]=VectFact[j].Number) and (KA=1) then

combobox2.Items.Add(VectFact[j].Znach);

end;

KA:=0;

for i:=1 to NF1 do

for j:=1 to NFF do

begin

if (SpisF[i]=VectFact[j].Number) and (KA=0) then

begin

combobox1.Text:=VectFact[j].Znach;

KA:=1;

end;

if (SpisF[i]=VectFact[j].Number) and (KA=1) then

combobox1.Items.Add(VectFact[j].Znach);

end;

end;

end;

if (Nk=0) and (NF1=0) then

begin

Application.MessageBox(' !','',mb_iconwarning);

BitBtn5.Enabled:=true;

end;

end;

procedure TForm1.BitBtn6Click(Sender: TObject);

begin

listbox4.Items.Clear;

listbox6.Items.Clear;

label10.Caption:=' ';

label8.Caption:=' ';

Label10.Font.Color:=cllime;

Label8.Font.Color:=cllime;

NK:=0;

NF1:=0;

label13.Visible:=false;

label13.Top:=104;

ComboBox1.Clear;

ComboBox2.Clear;

BitBtn5.enabled:=true;

end;

procedure TForm1.Timer2Timer(Sender: TObject);

begin

label13.Visible:=true;

label13.top:=label13.top+2;

if label13.top=150 then

timer2.Enabled:=false;

end;

procedure TForm1.LoadBase;

var

i:integer;

FF: TFF;

FactFile:TFactFile;

begin

i:=0;

OpenDialog1.Filter:=' |*.dat';

if not OpenDialog1.Execute then

exit;

if FileExists(OpenDialog1.FileName)=false then

begin

Application.MessageBox(' !','Error',MB_iconwarning);

exit;

end

else

begin

AssignFile(FF,OpenDialog1.FileName);

reset(FF);

NR:=0;

NFF:=0;

While Not eof(FF) do

begin

Read(FF,FactFile);

NFF:=NFF+1;

VectFact[NFF].Number:=FactFile.Number;

VectFact[NFF].Znach:=FactFile.Znach;

ListBox3.Items.Add(VectFact[NFF].Znach);

ListBox1.Items.Add(VectFact[NFF].Znach);

if FactFile.Q>1 then

begin

NR:=NR+1;

BaseKnow.Rule[NR].Number:=FactFile.Number;

BaseKnow.Rule[NR].Zel:=FactFile.Zel;

ListBox5.Items.Add(FactFile.Znach);

BaseKnow.Rule[NR].Q:=FactFile.Q;

for i:=1 to BaseKnow.Rule[NR].Q do

BaseKnow.Rule[NR].FactIn[i]:=FactFile.FactIn[i];

end;

end;

end;

closefile(FF);

end;

procedure TForm1.SpeedButton6Click(Sender: TObject);

var

inf:integer;

begin

inf:=Application.Messagebox(' ?','Question',MB_YESNO+MB_ICONQUESTION);

if inf=idNO then

exit;

if inf=idYes then

begin

ListBox1.Clear;

ListBox2.Clear;

ListBox3.Clear;

ListBox4.Clear;

ListBox5.Clear;

ListBox6.Clear;

LoadBase;

end;

end;

procedure TForm1.SaveBase;

var i,k,j:integer;

FF: TFF;

FactFile:TFactFile;

begin

SaveDialog1.Filter:=' |*.dat';

if SaveDialog1.Execute then

begin

assignfile(FF,SaveDialog1.filename);

rewrite(FF);

for i:=1 to NFF do

Begin

FactFile.Number:=VectFact[i].Number;

FactFile.Znach:=VectFact[i].Znach;

FactFile.Q:=0;

FactFile.Zel:=0;

for j:=1 to NR do

if VectFact[i].Number=BaseKnow.Rule[j].Number then

begin

FactFile.Q:= BaseKnow.Rule[j].Q;

FactFile.Zel:= BaseKnow.Rule[j].Zel;

for k:=1 to BaseKnow.Rule[j].Q do

FactFile.FactIn[k]:=BaseKnow.Rule[j].FactIn[k];

end;

write(ff,FactFile);

end;

end

else exit;

closefile(FF);

end;

procedure TForm1.SpeedButton7Click(Sender: TObject);

begin

SaveBase;

end;

procedure TForm1.ListBox1Click(Sender: TObject);

var

i,j,rab,r,t:integer;

begin

label6.Visible:=true;

t:=0;

ListBox2.Clear;

rab:=ListBox1.Itemindex;

for i:=1 to NR do

if VectFact[rab+1].Number=BaseKnow.Rule[i].Number then

begin

t:=1;

for j:=1 to BaseKnow.Rule[i].Q do

for r:=1 to NFF do

if VectFact[r].Number=BaseKnow.Rule[i].FactIn[j]then

ListBox2.Items.Add(VectFact[r].Znach);

end;

if t=1 then

label6.Caption:=' ';

if t=0 then

label6.Caption:=' ';

{}

end;

procedure TForm1.SpeedButton4Click(Sender: TObject);

begin

speedbutton6.Enabled:=false;

speedbutton7.Enabled:=false;

speedbutton8.Enabled:=false;

panel1.Visible:=true;

edit1.Visible:=true;

combobox3.Visible:=true;

radiogroup1.Visible:=true;

radiogroup1.ItemIndex:=0;

Num:=0;

edit1.SetFocus;

edit1.Clear;

end;

procedure TForm1.SpeedButton10Click(Sender: TObject);

begin

panel1.Visible:=false;

edit1.Visible:=false;

combobox3.Visible:=false;

radiogroup1.Visible:=false;

speedbutton11.visible:=false;

speedbutton6.Enabled:=true;

speedbutton7.Enabled:=true;

speedbutton8.Enabled:=true;

end;

procedure TForm1.RadioGroup1Click(Sender: TObject);

begin

if radiogroup1.ItemIndex=0 then

begin

combobox3.Enabled:=false;

label14.Enabled:=false;

speedbutton11.visible:=false;

edit1.SetFocus;

end;

if radiogroup1.ItemIndex=1 then

begin

combobox3.Enabled:=true;

label14.Enabled:=true;

speedbutton11.visible:=true;

edit1.SetFocus;

end;

end;

procedure TForm1.AddSimpleFact;

var

i,t:integer;

r:string;

begin

r:=edit1.text;

for i:=1 to NFF do

if r=VectFact[i].Znach then

begin

Application.MessageBox(' !','',mb_iconwarning);

exit;

end;

t:=VectFact[NFF].Number;

NFF:=NFF+1;

VectFact[NFF].Number:=t+1;

VectFact[NFF].Znach:=r;

ListBox1.items.add(VectFact[NFF].Znach);

ListBox3.items.add(VectFact[NFF].Znach);

end;

procedure TForm1.AddComplexFact;

var

i,t:integer;

r:string;

begin

r:=edit1.text;

for i:=1 to NFF do

if r=VectFact[i].Znach then

begin

Application.MessageBox(' !','',mb_iconwarning);

exit;

end;

t:=VectFact[NFF].Number;

NFF:=NFF+1;

VectFact[NFF].Number:=t+1;

VectFact[NFF].Znach:=r;

ListBox1.items.add(VectFact[NFF].Znach);

ListBox3.items.add(VectFact[NFF].Znach);

ListBox5.items.add(VectFact[NFF].Znach);

NR:=NR+1;

BaseKnow.Rule[NR].Number:=VectFact[NFF].Number;

BaseKnow.Rule[NR].Q:=Num;

BaseKnow.Rule[NR].Zel:=1;

for i:=1 to Num do

BaseKnow.Rule[NR].FactIn[i]:=SpisF[i];

end;

procedure TForm1.SpeedButton9Click(Sender: TObject);

begin

if radiogroup1.ItemIndex=0 then

if edit1.Text='' then

begin

Application.MessageBox(' !','',mb_iconwarning);

exit;

end

else

AddSimpleFact;

if radiogroup1.ItemIndex=1 then

if (edit1.Text='') or (ComboBox3.Text='')or (Num=0)then

begin

Application.MessageBox(' !','',mb_iconwarning);

exit;

end

else

begin

AddComplexFact;

combobox3.Clear;

end;

edit1.Clear;

Num:=0;

end;

procedure TForm1.SpeedButton11Click(Sender: TObject);

var rab:integer;

begin

rab:=ListBox1.itemindex;

ComboBox3.Items.Add(VectFact[rab+1].Znach);

ComboBox3.ItemIndex:=0;

Num:=Num+1;

SpisF[Num]:=VectFact[rab+1].Number;

end;

procedure TForm1.DeleteFact;

var

i,j,rab,t,k:integer;

begin

rab:=ListBox1.ItemIndex+1;

k:=VectFact[rab].Number;

for i:=1 to NR do

for j:=1 to BaseKnow.Rule[i].Q do

if BaseKnow.Rule[i].FactIn[j]=k then

begin

Application.MessageBox(' , !','',mb_iconwarning);

exit;

end;

for i:=rab to NFF-1 do

begin

VectFact[i].Number:=VectFact[i+1].Number;

VectFact[i].Znach:=VectFact[i+1].Znach;

end;

NFF:=NFF-1;

for i:=1 to NR do

if k=BaseKnow.Rule[i].Number then

begin

for t:=i to NR-1 do

begin

BaseKnow.Rule[t].Number:=BaseKnow.Rule[t+1].Number;

BaseKnow.Rule[t].Q:=BaseKnow.Rule[t+1].Q;

BaseKnow.Rule[t].Zel:=BaseKnow.Rule[t+1].Zel;

for j:=1 to BaseKnow.Rule[t].Q do

BaseKnow.Rule[t].FactIn[j]:=BaseKnow.Rule[t+1].FactIn[j];

end;

NR:=NR-1;

end;

ListBox1.Clear;

ListBox2.Clear;

ListBox3.Clear;

ListBox5.Clear;

for i:=1 to NFF do

begin

ListBox1.Items.Add(VectFact[i].Znach);

ListBox3.Items.Add(VectFact[i].Znach);

for j:=1 to NR do

if VectFact[i].Number=BaseKnow.Rule[j].Number then

ListBox5.Items.Add(VectFact[i].Znach);

end;

end;

procedure TForm1.SpeedButton5Click(Sender: TObject);

var

inf:integer;

begin

inf:=Application.Messagebox(' ?','Question',MB_YESNO+MB_ICONQUESTION);

if inf=idNO then

exit;

if inf=idYes then

DeleteFact;

end;

procedure TForm1.BitBtn2Click(Sender: TObject);

var

rab,i,j:integer;

begin

if NF1>0 then

begin

rab:=ListBox4.Itemindex;

for i:=rab+1 to NF1-1 do

begin

SpisF[i]:=SpisF[i+1];

BaseKnow.Fact[i]:=BaseKnow.Fact[i+1];

end;

NF1:=NF1-1; NF:=NF1;

ListBox4.Clear;

for i:=1 to NF1 do

for j:=1 to NFF do

if SpisF[i]=VectFact[j].Number then

ListBox4.Items.Add(VectFact[j].Znach);

end;

end;

procedure TForm1.BitBtn4Click(Sender: TObject);

var

rab,i,j:integer;

begin

if NK>0 then

begin

rab:=ListBox6.Itemindex;

for i:=rab+1 to NK-1 do

Knowledge[i]:=Knowledge[i+1];

NK:=NK-1;

ListBox6.Clear;

for i:=1 to NK do

for j:=1 to NFF do

if Knowledge[i]=VectFact[j].Number then

ListBox6.Items.Add(VectFact[j].Znach);

end;

end;

procedure TForm1.N5Click(Sender: TObject);

begin

HelpBox.show;

end;

procedure TForm1.N4Click(Sender: TObject);

begin

close;

end;

end.

5.2.







,



 , ⠠

PAGE 13

PAGE 1

1. , . : *

 

 

 

! , , , .
. , :