home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / mailpro / subedit.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-08-23  |  4.6 KB  |  134 lines

  1. unit SubEdit;
  2.  
  3. interface
  4. uses Crt,      Def,     ColorDef, PrtSDiv, GetKeU, FastWr, LPaU, CPaU,
  5.      RE,      Swap,     GetForU, StrnU;
  6. procedure EditSubDivision( var Division: integer; var Change: boolean);
  7.  
  8. implementation
  9.  
  10. procedure EditSubDivision;
  11. var FunctionKey,
  12.     AllowInput,
  13.     Continue:                 boolean;
  14.     Ch2,
  15.     Ch:                       char;
  16.     Swap1,
  17.     Swap2,
  18.     OCh,
  19.     RecNumber,
  20.     UseDivision,
  21.     AllowControl,
  22.     N1,
  23.     N2:                       integer;
  24.     Temp2,
  25.     Temp:                     s30;
  26. begin
  27. Continue := true;
  28. UseDivision := Division;
  29. Division := 0;
  30. while Continue do
  31.    begin
  32.    PrintSubDivision(UseDivision);
  33.    GetKey(Ch,FunctionKey);
  34.    AllowControl := -1;
  35.    AllowInput := true;
  36.    Ch := upcase(Ch);
  37.    N1 := ord(Ch);
  38.    if (N1 = 59) and FunctionKey then
  39.       N1 := -1
  40.      else
  41.       if (N1 = 63) and FunctionKey then
  42.          N1 := -2
  43.         else
  44.          if (N1 > 64) and (N1 < 91) then
  45.             N1 := N1 - 64
  46.            else
  47.             N1 := 0;
  48.    case N1 of
  49.       -2:  begin
  50.            FastWrite(LPad('First letter to swap ?',40), 21, 1, Inputs.Attr);
  51.            GetKey(Ch,FunctionKey);
  52.            Ch := upcase(Ch);
  53.            OCh := ord(Ch);
  54.            if (OCh >= 65) and (OCh <= 90) then
  55.               begin
  56.               Swap1 := OCh - 64;
  57.               FastWrite(LPad('Second letter to swap ?',40), 21, 1, Inputs.Attr);
  58.               GetKey(Ch,FunctionKey);
  59.               Ch := upcase(Ch);
  60.               OCh := ord(Ch);
  61.               if (OCh >= 65) and (OCh <= 90) and (OCh <> Swap1+64) then
  62.                  begin
  63.                  Swap2 := OCh - 64;
  64.                  FastWrite( BlankLine, 21, 1, Displays.Attr);
  65.                  FastWrite( CPad( 'Swap:  "'+AlphaCode[UseDivision,Swap1]+'" & "'+
  66.                             AlphaCode[UseDivision,Swap2]+'"   (Y/N)  ',80),
  67.                             1, 21, Inputs.Attr);
  68.                  GetKey(Ch,FunctionKey);
  69.                  Ch := upcase(Ch);
  70.                  if Ch = 'Y' then
  71.                     begin
  72.                     Change := true;
  73.                     SwapS(AlphaCode[UseDivision,Swap1],AlphaCode[UseDivision,Swap2]);
  74.                     FastWrite( BlankLine, 21, 1, Displays.Attr);
  75.                     FastWrite( 'Modifying record:', 1, 21, Msgs.Attr);
  76.                     for RecNumber := 1 to FileTop do
  77.                         begin
  78.                         if (RecNumber mod 10) = 0 then
  79.                            begin
  80.                            str(RecNumber,Temp2);
  81.                            FastWrite( Temp2, 21, 21, (Msgs.Attr or $0008));
  82.                            end;
  83.                         GetRec( HoldEntry, RecNumber);
  84.                         if  (HoldEntry.SubDivision = chr(Swap1))
  85.                         and (HoldEntry.Division    = chr(UseDivision)) then
  86.                            begin
  87.                            HoldEntry.SubDivision := chr(Swap2);
  88.                            PutRec(HoldEntry,RecNumber);
  89.                            end
  90.                           else
  91.                            begin
  92.                            if  (HoldEntry.SubDivision = chr(Swap2))
  93.                            and (HoldEntry.Division    = chr(UseDivision)) then
  94.                               begin
  95.                               HoldEntry.SubDivision := chr(Swap1);
  96.                               PutRec(HoldEntry,RecNumber);
  97.                               end;
  98.                            end;
  99.                         end;
  100.                     end;
  101.                  end;
  102.               end;
  103.            end;
  104.       -1:  begin
  105.            Change := true;
  106.            FastWrite( BlankLine, 21, 1, Displays.Attr);
  107.            FastWrite( 'Select a letter', 21, 1, Inputs.Attr);
  108.            GetKey(Ch,FunctionKey);
  109.            Ch := upcase(Ch);
  110.            N2 := ord(Ch);
  111.            if N2 = 59 then N2 := -1 else
  112.               if (N2 > 64) and (N2 < 91) then N2 := N2 - 64;
  113.            FastWrite( BlankLine, 21, 1, Displays.Attr);
  114.            FastWrite( 'AlphaCode for subdivision '+chr(N2+64), 21, 1, Inputs.Attr);
  115.            Temp := GetForm( 40, 21, 30, Strng(30,#32),
  116.                             AlphaCode[UseDivision,N2], AllowControl,
  117.                             AllowInput, Inputs.Attr, [#32..#126]);
  118.            if (N2 >= 1) and (N2 <= SubDivisionTop) then
  119.               begin
  120.               AlphaCode[UseDivision,N2] := Temp;
  121.               end;
  122.            end;
  123.        1..SubDivisionTop :begin
  124.            Entry.SubDivision := chr(N1);
  125.            Division := N1;
  126.            Continue := false;
  127.            end;
  128.        end;        (* case *)
  129.    end;            (* while *)
  130. end;
  131.  
  132. end.
  133. 
  134.