Скачиваний:
126
Добавлен:
08.05.2014
Размер:
6.88 Кб
Скачать
{ (c) Coded by Alexey Semenov, 2000 }
Program TurboVision(LabJob7);
Uses App, Objects, Menus, Drivers, Views, Dialogs, MsgBox;
type
TMyApp = Object(TApplication)
procedure HandleEvent(var Event: TEvent); virtual;
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
function MakeDialogMonitor: PDialog; virtual;
function MakeDialogHDD: PDialog; virtual;
function MakeDialog3(nomer: integer) : PDIalog; virtual;
end;
Data = Record
shop: string[11];
typeCP: string[7];
FReq: string [3];
OZU: string[4];
NGMD: string[4];
GMD: string[2];
monitor: string[5];
cena: integer;
end;
const
cm0 = 200;
cm1 = 201;
cm2 = 202;
path = 'Z:\SUXX';
var
MyApp: TMyApp;
base: array[1..10] of data;
f: text;
i: integer;

{------------- TMyApp.MakeDialogMonitor --------------}

Function TMyApp.MakeDialogMonitor: PDialog;
var
Dlg: PDialog;
R: TRect;
B: PView;
begin
R.Assign(20,5,57,15);
New(Dlg, Init(R, 'Monitor Type'));
with Dlg^ do
begin
R.Assign(6,4,20,7);
B := New (PRadioButtons, Init (R,
NewSItem('~M~ono',
NewSItem('~V~GA',
NewSItem('~S~VGA', nil)))));
Insert(B);
R.Assign(6,2,25,3);
Insert(New(PLabel,Init(R, 'Monitor Type', B)));
R.Assign(23,5,33,7);
Insert(New(PButton, Init(R, '~O~K', cmOK, bfDefault)));
end;
SelectNext(False);
MakeDialogMonitor := Dlg;
end;

{------------- TMyApp.MakeDialogHDD --------------}

Function TMyApp.MakeDialogHDD: PDialog;
var
Dlg: PDialog;
R: TRect;
B: PView;
begin
R.Assign(16,5,61,15);
New(dlg, Init(R, 'HDD Size'));
with Dlg^ do
begin
R.Assign(4,4,28,7);
B := New(PRadioButtons, Init(R,
NewSItem('~4~0 Mb',
NewSItem('~8~9 Mb',
NewSItem('~1~20 Mb',
NewSItem('~2~40 Mb',
NewSItem('~3~40 Mb',
NewSItem('~5~20 Mb', nil))))))));
Insert(B);
R.Assign(6,2,25,3);
Insert(New(PLabel, Init(R, ' HDD Size', B)));
R.Assign(31,5,41,7);
Insert(New(PButton, Init(R, '~O~K', cmOk, bfDefault)));
end;
SelectNext(False);
MakeDialogHDD := Dlg;
end;

{------------- TMyApp.MakeDialog3 --------------}

Function TMyApp.MakeDialog3 (nomer:integer): PDialog;
var
Dlg: PDialog;
R: TRect;
B: PView;
a: string;
begin
R.Assign(20,5,60,19);
New(Dlg, Init(R, '‘ ¬л© ¤Ґисўл© Є®¬ЇмовҐа'));
with Dlg^ do
begin
R.Assign(2,2,20,3);
Insert(New(PLabel,Init(R, 'Firm: ', B)));
R.Assign(20,2,30,3);
Insert(New(PLabel, Init(R, base[nomer].shop, B)));
R.Assign(2,3,20,4);
Insert(New(PLabel, Init(R, 'Processor: ', B)));
R.Assign(20,3,30,4);
Insert(New(PLabel, Init(R, base[nomer].typeCP, B)));
R.Assign(2,4,20,5);
Insert(New(PLabel, Init(R, 'Frequency: ', B)));
R.Assign(20,4,30,5);
Insert(New(PLabel, Init(R, base[nomer].FReq, B)));
R.Assign(2,5,20,6);
Insert(New(PLabel, Init(R, 'RAM: ', B)));
R.Assign(20,5,30,6);
Insert(New(PLabel, Init(R, base[nomer].OZU, B)));
R.Assign(2,6,20,7);
Insert(New(PLabel, Init(R, 'HDD Size: ', B)));
R.Assign(20,6,30,7);
Insert(New(PLabel, Init(R, base[nomer].NGMD, B)));
R.Assign(2,7,20,8);
Insert(New(PLabel, Init(R, 'Floppy Quantity: ', B)));
R.Assign(20,7,30,8);
Insert(New(PLabel, Init(R, base[nomer].GMD, B)));
R.Assign(2,8,20,9);
Insert(New(PLabel, Init(R, 'Monytor Type: ', B)));
R.Assign(20,8,30,9);
Insert(New(PLabel, Init(R, base[nomer].monitor, B)));
R.Assign(2,9,20,10);
str(base[nomer].cena, a);
Insert(New(PLabel, Init(R, 'Price: ', B)));
R.Assign(20,9,30,10);
Insert(New(PLabel, Init(R, a, B)));
R.Assign(15,11,25,13);
Insert(New(PButton, Init(R, '~O~k',
cmCancel, bfDefault)));
end;
SelectNext(False);
MakeDialog3 := Dlg;
end;

{------------- TMyApp.HandleEvent --------------}

Procedure TMyApp.HandleEvent(var Event: TEvent);
var
Selection: word;
temp: string;
oldcena: integer;
numer: integer;
begin
inherited HandleEvent(Event);
if Event.What <> evCommand then Exit;
case Event.Command of
cm0:
begin
Selection := 0;
if ExecuteDialog(MakeDialogMonitor, @Selection) <> cmOk then
begin
ClearEvent(Event);
Exit;
end;
case Selection of
0: temp := 'Mono ';
1: temp := 'VGA ';
2: temp := 'SVGA ';
end;
oldcena := 30000;
for i:=1 to 10 do
begin
with base[i] do
begin
if (monitor = temp) and (cena < oldcena) then
begin
oldcena := cena;
numer := i;
end;
end;
end;
ExecuteDialog(MakeDialog3(numer),@Selection);
ClearEvent(Event);
end;
cm1:
begin
Selection := 0;
if ExecuteDialog(MakeDialogHDD, @Selection) <> cmOk then
begin
ClearEvent(Event);
Exit;
end;
case Selection of
0: temp := '40 ';
1: temp := '89 ';
2: temp := '120 ';
3: temp := '240 ';
4: temp := '340 ';
5: temp := '520 ';
end;
oldcena := 30000;
for i:=1 to 10 do
begin
with base[i] do
begin
if (ngmd = temp) and (cena < oldcena) then
begin
oldcena := cena;
numer := i;
end;
end;
end;
ExecuteDialog(MakeDialog3(numer),@Selection);
ClearEvent(Event);
end;
end;
end;

{------------- TMyApp.InitStatusLine ---------------}

Procedure TMyApp.InitStatusLine;
var
R: TRect;
begin
GetExtent(R);
R.A.Y := R.B.Y - 1;
New(StatusLine, Init (R,
NewStatusDef(0, $EFFF,
NewStatusKey('~Alt+X~ Exit', kbAltX, cmQuit,
NewStatusKey('~F10~ Menu', kbF10, cmMenu,
NewStatusKey('~Alt+F3~ Close', kbAltF3, cmClose,
nil))),
nil)));
end;

{------------- TMyApp.InitMenuBar ---------------}

Procedure TMyApp.InitMenuBar;
var
R : TRect;
begin
GetExtent(R);
R.B.Y := R.A.Y + 1;
MenuBar := New (PMenuBar, Init(R, NewMenu(
NewItem('~M~onitor Type', '', kbNoKey, cm0, hcNew,
NewItem('HDD ~S~ize', '', kbNoKey, cm1, hcOpen,
nil)))));
end;

{--------------- Џ ђ Ћ ѓ ђ Ђ Њ Њ Ђ ----------------}

begin
Assign(f, path + 'hwpc.txt');
Reset(f);
for i:=1 to 6 do ReadLn(f);
for i:=1 to 10 do
begin
with base[i] do
begin
Read(f, shop);
Read(f, typeCP);
Read(f, FReq);
Read(f, OZU);
Read(f, NGMD);
Read(f, GMD);
Read(f, monitor);
Readln(f, cena);
end;
end;
Close(f);
MyApp.Init;
MyApp.Run;
MyApp.Done;
end.
Соседние файлы в папке задание №7 — 7