| | KyMa 
 Newbie
 | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Привет, народ!мне оч. оч. оч. нужна ваша помощь. У меня такая задача...
 
 Создать программу, которая состоит из трёх пунктов меню:первый - база данных, содержащая в себе начальные и конечные пункты маршрутов автобусов, а также их номера; второй - по введённому номеру автобуса выводит начальный и конечные пункты; третий - выход.
 
 У меня получилось сделать все, кроме втрого пункта, программа почему -то не нв ыводит на экран базу данных, когда я ввожу номер маршрута, помогите пожалуйста разобраться с этой проблемой.
 
 
 {$M 65000,0,655360}
 program Mobile_base;
 uses Crt;
 const
 n_items=3;                              { KOflH4ecTBO nyHKTOB}
 l_dbase=500;                          { MaKCHMajibHbiii pasuep 6a3bi}
 l_model=20;                            {}
 type
 Tel=record                             {   inn oflHow sanncn e 6ase}
 model:string[l_model];
 weight,price:real;
 end;
 
 Tbase=array[1..l_dbase] of Tel;                          { iMn 6asbi}
 var
 DefaultMode,ActiveColor,InactiveColor:word;
 base:Tbase;                              {   6aaa ie^e$OHOB }
 n,item,prev:word;                                {   ^aKTHHecKoe KO/inHecTBo 3annceti B 6ase }
 key:char;                                {   K^aBwuia. Hawaraji
 { ------   BbiBOfl 6a3bi}
 procedure ShowBase(const base:Tbase; n:word);
 const
 step=18;                                    { KOJinHecTBo cipOK B OKHe}
 var
 i,beg:integer;                         { Honepa cipoK npw}
 key:char;
 begin
 window(3,4,78,24);
 TextBackGround(LightGray);
 TextColor(white);
 beg:=1;
 while true do
 begin                              { qnKji npocMorpa cnncKa.  Bbixofl - esc }
 clrscr;
 gotoXY(1,1);
 writeln('     Nachal                   Conechn                   Nomer');
 for i:=beg to beg+step do                       { ^mn Bbisofla oflHo}
 if i>n then break
 else with base[i] do                            { Bbieon crpoKn cnncKa}
 writeln(' ',model,weight:5:2,price:15:2);
 key:=readkey;
 if key=#0 then key:=readkey;       { Hawarne KnaBHujn npOKpyiKH }
 case ord(key) of
 27:exit;                                                   { Bbixofl M3 npoCMotpa no Hawaiw Esc }
 13,80,81:begin
 inc(beg,step);
 if beg>n then beg:=n;
 end;
 72,73:begin
 dec(beg,step);
 if beg<1 then beg:=1;
 end;
 end;
 end;
 end;
 { - - BbiBOfl nyHKia weHK) - - }
 procedure DrawItem(item, color: word);
 const
 l_item=20;                                                                      { flnnHa nyHKia}
 items:array[1..n_items] of string[l_item]=('Choise the base','Choise','Exit');                                { nyHKTbi}
 pos:array[1..n_items] of integer=(1, l_item+1, 2*l_item+1);    { nosnunn Hana^a nyHKtoB nem }
 begin
 window(1,1,80,2);
 TextBackGround(LightGray);
 TextColor(color);
 gotoXY(pos[item],1);
 write(items[item]);
 end;
 { -  - AaapnMHoe aasepujeHne nporpaMMbi     - }
 procedure Error(message:string);
 begin
 window(1,1,80,25);
 TextAttr:=Red+Blink;
 clrscr;
 gotoXY(35,12);
 write(message);                            { BbiBOfl npHHWHbi ociaHOBa }
 repeat until keypressed;
 halt;
 end;
 
 { --  ------ OHMCTKa pa6oHeii o6nacTM -  - }
 procedure Clear;
 begin
 window(1,3,80,25);
 TextAttr:=White;
 clrscr;
 end;
 
 { -- -   BblBOfl   Te^e$OHOB,   COOTBeTCTByKWX   KpHTepHflM   -   }
 procedure ShowSelected(const base:Tbase; n:word);
 var
 startprice,endprice:real;       { MHHHManbHafl n M3KCMManbHaa uena }
 selectedbase: Tbase;      { 8bi6opKa M3 6a3bi }
 n_sel:word;         { KonnnecTBo crpon a ew6opKe }
 
 {KpnTepneB Bti6opa iene$OHOB -                    - }
 
 procedure Query(var StartPrice,EndPnce:real);
 type Route=record
 Road_Begin : string;
 Road_End : string;
 Road_Num : integer;
 end;
 var
 s:string;         { 6y$ep nnn BBOfla   ueHbi }
 err:integer;
 arr_route:array [1..8] of Route;
 check_find,i, r_num : integer;
 r_beg, r_end, path_file, text_string : string;
 question : char;
 f :Text;
 { napaneTp oujM6KM npw npeo6pasoBaHMM e Hncno }
 begin
 window(10,6,70,12);
 TextAttr:=Green+LightGray*16;
 clrscr;
 { noKa nojib30Baienb He BBenei M3KC. 6onbue MHH. }
 
 gotoXY(2,2);
 write('nomer ');
 readln(r_num);
 arr_route[i].road_num := r_num;
 for  writeln('Save to File? y\n');
 readln(question);
 if (question = 'y') or
 (question = 'Y') then
 begin
 writeLn('Enter the Path and FileNa
 ReadLn(path_file);
 i :=1 to 8 do
 Assign(f,path_file);
 Rewrite(f);  begin
 
 writeln(f, arr_route[i].road_begin);
 writeln(f, arr_route[i].road_end);
 writeln(f, arr_route[i].road_num);
 end;
 close(f);
 end;
 
 writeln('Enter race to Searching: ');
 readln(r_beg);
 check_find := 0;
 
 for i:= 1 to 8 do
 begin
 if (arr_route[i].road_begin = r_beg) or
 (arr_route[i].road_end = r_beg) then
 begin
 writeLn('Find  ','E: ', arr_route[i].road_num,' Begin:',arr_route[i].road_begin,' End:',arr_route[i].road_end );
 check_find := 1;
 end;
 
 if check_find = 0 then
 WriteLn('Record not Found!');
 end;
 end;
 { - Bbi6op M3 6a3bi no KpnTepnan -    - }
 procedure Select(StartPrice,EndPrice:real;
 const base:Tbase; n:word;
 var selectedbase: Tbase;
 var m: word);
 var
 i:word;
 begin
 m:=0;
 for i:=1 to n do
 with base[i] do
 if (price>=StartPrice) and (price<=EndPrice) then
 begin
 inc(m);
 selectedbase[m]:=base[i];
 end;
 end;
 
 begin
 Query(StartPrice,EndPrice);                { 3anpoc napaMerpoB }
 Select(StartPrice,EndPrice,base,n,selectedbase,n_sel);      { BbiSopna }
 ShowBase(selectedbase,n_sel);   { BbiBOfl Bbi6paHHbix cipoK }
 end;
 
 { - 4reHne n3 $aiifla}
 procedure ReadFile(var base:Tbase; var n:word);
 var
 f:text;
 begin
 {$I-}
 assign(f,'e:\phone.txt');
 reset(f);
 if(IOResult<> 0) then Error('ft.txt not found');
 n:=0;
 while not Eof(f) do
 begin
 inc(n);
 if n>l_dbase then Error('Out of range for array BASE');
 with base[n] do readln(f,model,weight,price);
 end;
 close(f)
 {$I+}
 end;
 
 procedure InitMenu(ActiveColor,InactiveColor:word);
 var
 item:word;
 begin
 window(1,1,80,2);
 TextBackGround(LightGray);
 clrscr;
 DrawItem(1,ActiveColor);
 for item:=2 to n_items do DrawItem(item,InactiveColor);
 gotoXY(1,2);
 TextColor(InactiveColor);
 write('-------------------------------------------------------');
 gotoXY(1,1);
 end;
 { =========================== rnaBHaa nporpawMa =====================}
 
 Begin
 DefaultMode:=LastMode;
 TextMode(C80);
 ReadFile(base,n);        { HieHne 6asbi n3}
 clrscr;
 ActiveColor:=LightGreen;
 InactiveColor:=Green;
 InitMenu(ActiveColor,InactiveColor);
 
 { MHnunannsauMfi}
 item:=1;
 prev:=1;
 while true do
 begin           { unKn Bbi6opa nyHKia}
 key:=readkey;
 if key=#0 then key:=readkey;
 case ord(key) of
 13: case item of      { enter - BbinonHeHne nyHKta}
 1:ShowBase(base,n);
 2:ShowSelected(base,n);
 3:exit;            { Btixofl n3 nporpanMbi}
 end;
 15,75:begin            { nepene^eHne}
 prev:=item;
 dec(item);
 if item=0 then item:=n_items;
 end;
 9,77:begin
 prev:=item;
 inc(item);
 if item=n_items+1 then item:=1;
 end;
 end;
 Clear;
 DrawItem(prev,InactiveColor);         { BbiBOfl npeflbinymero   nyHKia}
 DrawItem(item,ActiveColor);           { Bbisofl Bti6paHHoro nyHKia }
 end;
 TextMode(DefaultMode);    { BosspaT K npeflbinymeMy pewnwy }
 End.
 
 
 
 
 бАЗА ДАННЫХ
 sherstneva       kirova        27
 vorgashor        gorod         104
 gorod            severnyi      103
 lenina           timan         25
 metallistov      timan         26
 sovetskiy        gorod         20
 vokzal           lenina        23
 vorgashor        shaxta v      85
 |  | Всего записей: 12 | Зарегистр. 19-11-2006 | Отправлено:  22:53 14-04-2007  | Исправлено: KyMa,   22:57 14-04-2007
 | 
 |