Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
{ OPTION.PAS                Copyright (c) TrSek alias Zdeno Sekerak }
{ Rutiny pre nacitanie alebo modifikaciu nastaveni programu.        }
{ Obdoba *.ini suboru.                                              }
{                                                                   }
{ Datum:19.06.1995                            http://www.trsek.com  }
 
procedure default;
begin
    base[realy_find('POMEST')]:=stri(d_pomest,2);
    base[realy_find('FOMEST')]:=stri(d_fomest,2);
    base[realy_find('PNMEST')]:=stri(d_pnmest,2);
    base[realy_find('FNMEST')]:=stri(d_fnmest,2);
    base[realy_find('PVMEST')]:=stri(d_pvmest,2);
    base[realy_find('FVMEST')]:=stri(d_fvmest,2);
    base[realy_find('POZALU')]:=stri(d_pozalu,2);
    base[realy_find('FOZALU')]:=stri(d_fozalu,2);
    base[realy_find('PNZALU')]:=stri(d_pnzalu,2);
    base[realy_find('FNZALU')]:=stri(d_fnzalu,2);
    base[realy_find('PVZALU')]:=stri(d_pvzalu,2);
    base[realy_find('FVZALU')]:=stri(d_fvzalu,2);
    base[realy_find('PVHELP')]:=stri(d_pvhelp,2);
    base[realy_find('FVHELP')]:=stri(d_fvhelp,2);
    base[realy_find('PNHELP')]:=stri(d_pnhelp,2);
    base[realy_find('FNHELP')]:=stri(d_fnhelp,2);
    base[realy_find('PTLAC')]:=stri(d_ptlac,2);
    base[realy_find('FTLAC')]:=stri(d_ftlac,2);
    base[realy_find('FAX_TYP')]:=stri(d_typ_ffax,2);
    base[realy_find('DOBA_DOD')]:=stri(d_doba_dod,3);
    base[realy_find('PORADIE')]:='poradie';
    base[realy_find('POC_FZAL')]:=stri(d_poc_fzal,2);
    base[realy_find('LAV_KRAJ')]:=stri(d_lav_kraj,2);
    base[realy_find('CEN_DEA')]:=stri(d_cen_dea,3);
    base[realy_find('CEN_MER')]:=stri(d_cen_mer,3);
    base[realy_find('CEN_MON')]:=stri(d_cen_mon,3);
end;
 
procedure options(make:byte);
 
var     veta:integer;
  hlada,y,ys:integer;
          ch:char;
     s1,s2,s:string;
         vst:boolean;
   hore,dole:boolean;
         def:double;
begin
 def:=0;
 opendbase(option);
 cit_vety(option,1);
 
 if make=2 then begin
    default;
    zap_vety(option,1);
  end;
 
 if make=1 then begin
  farba(BLUE,YELLOW);
  okno(1,1,80,24,' Nastavenie ',' F4-Default ESC-Exit CRTL[znak]-Polozka ',pozalu);
  if view_frm(option)=0 then exit;
  veta:=poc;y:=1;vst:=false;                   { Pociatocna veta je posledna }
  dole:=true;hore:=false;
 
 if poc=0 then begin                          { ak je nahodou ciste DBF }
    poc:=1;veta:=poc;
    for i:=1 to max_viet do base[i]:=nothing(hlavy[i].size);
    s:=stri(poc,hlavy[formular[1].pol].size);
    for i:=1 to length(s) do base[formular[1].pol][i]:=s[i];
    zap_vety(option,veta);
    end;
 
 farba(pnzalu,fnzalu);
 quick_view_all(def,def,false);
 
 repeat
  farba(pvzalu,fvzalu);
  view_pol(y);
  kurzorzap(false);
 
  ch:=readkey;
 
  if ctrl_akt then begin
     farba(pnzalu,fnzalu);view_pol(y);
     ys:=find_p( UpCase( chr(ord(ch)+64) ) );
     if ys<>0 then y:=ys;
     ch:=#1;
    end;
 
  if ch=#0 then begin
     ch:=readkey;
     case (ch) of
 
       #62: begin
             default;
             farba(pnzalu,fnzalu);
             quick_view_all(def,def,false);
            end;
 
       #72: begin                       { sipka hore }
             farba(pnzalu,fnzalu);view_pol(y);
             hore:=true;dole:=false;
             y:=y-1;if y<1 then y:=1;
            end;
 
       #80: begin                       { sipka dole }
             farba(pnzalu,fnzalu);view_pol(y);
             y:=y+1;
             hore:=false;dole:=true;
            end;
 
         else begin
              base[formular[y].pol]:=uprav_pol(formular[y].pol,tread2(y,base[formular[y].pol],base[formular[y].pol],#0,ch));
              farba(pnzalu,fnzalu);view_pol(y);vst:=true;
              end;
         end;
      ch:=#0;
     end;
 
                                                { vyplnovanie poloziek }
    if (ch in ['0'..'9','A'..'z',#13,#32]) then begin
       s:=strs(hlavy[formular[y].pol].nazov,true);
       vst:=true;
 
       if not (ch in [#13]) then begin
          if ch in ['0'..'9','A'..'z'] then        { bud edituje, alebo cisti polozku pre vyplnovanie }
             base[formular[y].pol]:=uprav_pol(formular[y].pol,tread2(y,nothing(hlavy[formular[y].pol].size),
                                              base[formular[y].pol],#13,ch))
           else
             base[formular[y].pol]:=uprav_pol(formular[y].pol,tread2(y,base[formular[y].pol],base[formular[y].pol],#13,ch));
          hlada:=vali(base[formular[y].pol]);
         end
        else hlada:=0;
 
     farba(pnzalu,fnzalu);
     quick_view_all(def,def,false);
     y:=y+1;
    end;
 
   if (formular[y].pol=0) then y:=y-1;
 
   vst:=false;
 until (ch=#27);                        { Koniec na ESC=#27     }
 zap_vety(option,veta);
 end;                                   { zapis poslednu editovanu vetu do DBF suboru }
 
 pomest:=vali(base[realy_find('POMEST')]);
 fomest:=vali(base[realy_find('FOMEST')]);
 pnmest:=vali(base[realy_find('PNMEST')]);
 fnmest:=vali(base[realy_find('FNMEST')]);
 pvmest:=vali(base[realy_find('PVMEST')]);
 fvmest:=vali(base[realy_find('FVMEST')]);
 pozalu:=vali(base[realy_find('POZALU')]);
 fozalu:=vali(base[realy_find('FOZALU')]);
 pnzalu:=vali(base[realy_find('PNZALU')]);
 fnzalu:=vali(base[realy_find('FNZALU')]);
 pvzalu:=vali(base[realy_find('PVZALU')]);
 fvzalu:=vali(base[realy_find('FVZALU')]);
 pvhelp:=vali(base[realy_find('PVHELP')]);
 fvhelp:=vali(base[realy_find('FVHELP')]);
 pnhelp:=vali(base[realy_find('PNHELP')]);
 fnhelp:=vali(base[realy_find('FNHELP')]);
 ptlac :=vali(base[realy_find('PTLAC')]);
 ftlac :=vali(base[realy_find('FTLAC')]);
 doba_dod:=vali(base[realy_find('DOBA_DOD')])-1;
 sirpap:=vali(base[realy_find('FAX_SIR')]);
 dlzpap:=vali(base[realy_find('FAX_DLZ')]);
 subor:=strs(base[realy_find('ZALU_FOR')],false);
 s_zost:=strs(base[realy_find('ZOST_FOR')],false);
 s_kumu:=strs(base[realy_find('KUMU_FOR')],false);
 poradie:=strs(base[realy_find('PORADIE')],false)+k_por;
 poc_fzal:=vali(base[realy_find('POC_FZAL')]);
 typ_ffax:=vali(base[realy_find('FAX_TYP')]);
 cen_dea:=vali(base[realy_find('CEN_DEA')]);
 cen_mer:=vali(base[realy_find('CEN_MER')]);
 cen_mon:=vali(base[realy_find('CEN_MON')]);
 lav_kraj:=vali(base[realy_find('LAV_KRAJ')]);
 if (strs(base[realy_find('KONIEC')],true)='n') or
    (strs(base[realy_find('KONIEC')],true)='N') then end_yn:=false
                                           else end_yn:=true;
end;