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

  1. unit SM;  { System Menu }
  2.  
  3. interface
  4. uses Crt,      Def,      FT,       ColorIU,  Str2InU,  MO,       DrawSqar,
  5.      ColorDef, FastWr,   CPaU,     GetForU,  StrnU,    Real2StU, GetKeU,
  6.      SetAttU,  LPaU,     StriU,    BeeU,     CursorOU, FR,       ShadoU,
  7.      PR,       RE,       SetBU,    UCasU,    Colors,   GenMenus, RenFile,
  8.      DelFile;
  9. procedure SetTopOfFile;
  10. procedure ModeMenu;
  11.  
  12. implementation
  13.  
  14. procedure SetTopOfFile;
  15. var Err,
  16.     AllowControl,
  17.     Num1,
  18.     Num2:                          integer;
  19.     TempStr:                       s10;
  20.     AllowInput:                    boolean;
  21. begin
  22. clrscr;
  23. AllowControl := -1;
  24. AllowInput := true;
  25. GetFileTop;
  26. {$i-}   assign(TempMainFile,DataDrive+'maillist');
  27. {$i+}   Err := ioresult;
  28. {$i-}   reset(TempMainFile);
  29. {$i+}   Err := ioresult;
  30. DrawSquare( 1, 1, 80, 7, Msgs.Attr, true);
  31. str(FileTop:5,TempStr);
  32. FastWrite( CPad('The program has a recorded end at record number '+TempStr,78),
  33.            2, 2, Msgs.Attr);
  34. str(filesize(TempMainFile):5,TempStr);
  35. FastWrite( CPad('The actual file size ends with record number    '+TempStr,78),
  36.            3, 2, Msgs.Attr);
  37. str(SortTop:5,TempStr);
  38. FastWrite( CPad('The recorded end of sorted records is located @ '+TempStr,78),
  39.            4, 2, Msgs.Attr);
  40. FastWrite( CPad('You may use any of these or pick your own.',78),
  41.            6, 2, Msgs.Attr);
  42.  
  43. FastWrite( CPad('What is the new last record for the file ?',60),
  44.            10, 10, Inputs.Attr);
  45. FastWrite( CPad('(0 = Use current program top).',60), 11, 10, Inputs.Attr);
  46. Num1 := 0;
  47. Err := 0;
  48. Num1 := Str2Int( GetForm( 38, 12, 6, Strng(6,#32), Strip(Real2Str(Num1,6,0)),
  49.                           AllowControl, AllowInput, Inputs.Attr, ['0'..'9']),
  50.                  Err);
  51. if (Err = 0) and (Num1 <> 0) then
  52.    begin
  53.    FileTop := Num1;
  54.    if SortTop > FileTop then SortTop := FileTop;
  55.    PutFileTop;
  56.    end;
  57.  FastWrite( CPad('What is the new last sorted record for the file ?',60), 14, 10, Inputs.Attr);
  58.  FastWrite( CPad('(0 = Use current sort top).',60), 15, 10, Inputs.Attr);
  59. Num2 := 0;
  60. Err := 0;
  61. Num2 := Str2Int( GetForm( 38, 16, 6, Strng(6,#32), Strip(Real2Str(Num2,6,0)),
  62.                           AllowControl, AllowInput, Inputs.Attr, ['0'..'9']),
  63.                  Err);
  64. if (Err = 0) and (Num2 <> 0) then
  65.    begin
  66.    SortTop := Num2;
  67.    if SortTop > FileTop then SortTop := FileTop;
  68.    PutFileTop;
  69.    end;
  70. {$i-}   close(TempMainFile);
  71. {$i+}   Err := ioresult;
  72. end;
  73.  
  74. procedure ModeMenu;
  75. var Col,
  76.     Row:                     integer;
  77.     FunctionKey:             boolean;
  78.     Ch:                      char;
  79.     Show:                    LineArray;
  80.  
  81.     (* ------------------------------- *)
  82.  
  83.     procedure DisplayMode;
  84.     var FunctionKey:        boolean;
  85.         Ch:                 char;
  86.         TempStr:            s10;
  87.         Show:               LineArray;
  88.         X:                  integer;
  89.     begin
  90.     str(ShowMode, TempStr);
  91.     Show[0] := 'Current mode for screen = '+TempStr;
  92.     Show[1] := '1. Phone number';
  93.     Show[2] := '2. Locale';
  94.     Show[3] := '3. Street address';
  95.     Show[4] := '4. Company and Title';
  96.     Ch := RetMenu( Show, 4, FunctionKey);
  97.     val(Ch,I,X);
  98.     if (I > 0) and (I < 5) then
  99.        begin
  100.        clrscr;
  101.        ShowMode := I;
  102.        PutMode(ShowMode,PrinterMode);
  103.        end;
  104.     end;
  105.  
  106.     (* ------------------------------- *)
  107.  
  108.     procedure PrintMenu;
  109.     var FunctionKey:             boolean;
  110.         Ch:                      char;
  111.         Show:                    LineArray;
  112.  
  113.        (* ---------------- *)
  114.  
  115.        procedure SetPrinterMode;
  116.        var FunctionKey:        boolean;
  117.            Ch:                 char;
  118.            TempStr:            s10;
  119.            Show:               LineArray;
  120.            X:                  integer;
  121.        begin
  122.        str(PrinterMode, TempStr);
  123.        Show[0] := 'Current mode for Printer = '+TempStr;
  124.        Show[1] := '1. Address list';
  125.        Show[2] := '2. Phone list';
  126.        Show[3] := '3. Both lists';
  127.        Show[4] := '4. All fields';
  128.        Ch := RetMenu( Show, 4, FunctionKey);
  129.        clrscr;
  130.        val(Ch,I,X);
  131.        if (I > 0) and (I < 5) then PrinterMode := I;
  132.        end;
  133.  
  134.        (* ---------------- *)
  135.  
  136.        procedure SetForms;
  137.        var Choice,
  138.            I,
  139.            OCh,
  140.            Temp,
  141.            Err:                integer;
  142.            FunctionKey:        boolean;
  143.            Ch:                 char;
  144.            A:                  array [1..LastDescription] of S5;
  145.            AltAttr:            byte;
  146.  
  147.            procedure SetHeadings;
  148.            begin
  149.            I := 0;
  150.            inc(I);   A[I] := 'ADDRS';
  151.            inc(I);   A[I] := 'TITLE';
  152.            inc(I);   A[I] := 'COMP.';
  153.            inc(I);   A[I] := 'AUX. ';
  154.            inc(I);   A[I] := 'MAIL.';
  155.            inc(I);   A[I] := 'CITY ';
  156.            inc(I);   A[I] := 'STATE';
  157.            inc(I);   A[I] := 'ZIP  ';
  158.            inc(I);   A[I] := 'PH 1 ';
  159.            inc(I);   A[I] := 'PH 2 ';
  160.            inc(I);   A[I] := 'CMNT.';
  161.            end;
  162.  
  163.            procedure SetXY(var I,X,Y: integer);
  164.            begin
  165.            X := succ(pred(I) div 20);        (* 1 or 2 *)
  166.            Y := succ(I - pred(X) * 20);      (* 2 - 21 *)
  167.            X := pred(X) * 40 + 3;            (* 3 or 43 *)
  168.               (* X is now 1 or 41 *)
  169.  
  170.               (* Y is now 2 - 21 *)
  171.               (*  2 =  1 or 21 *)
  172.               (*  .            *)
  173.               (*  .            *)
  174.               (*  .            *)
  175.               (* 21 = 20 or 40 *)
  176.            end;
  177.  
  178.            procedure FormsDisplay;
  179.            var X,
  180.                Y,
  181.                I:                   integer;
  182.                Show:                s2;
  183.                Temp:                s80;
  184.            begin
  185.            DrawSquare(1, 1, 80, 22, Menus.Attr, true);
  186.            for I := 1 to MaxForms do
  187.                begin
  188.                str(I, Show);
  189.                SetXY(I,X,Y);
  190.                FastWrite( Show, Y, X, (Menus.Attr or $0008) );
  191.                FastWrite( Form[I].Description, Y, X+3, (Menus.Attr or $0008) );
  192.                end;
  193.            DrawSquare(1, 23, 80, 25, Msgs.Attr, true);
  194.            Temp := '[ESC] = default selection   F2 = Select Form   F4 = Edit Form';
  195.            FastWrite( CPad(Temp,78), 24, 2, Msgs.Attr);
  196.            end;
  197.  
  198.            (* -------------------------------------------------------------------- *)
  199.  
  200.            procedure HighLightForm(I: integer);
  201.            var Show:                s2;
  202.                X,
  203.                Y:                  integer;
  204.            begin
  205.            str(I, Show);
  206.            SetXY(I,X,Y);
  207.            FastWrite( Show, Y, X, AltAttr );
  208.            FastWrite( Form[I].Description, Y, X+3, AltAttr );
  209.            end;
  210.  
  211.            (* -------------------------------------------------------------------- *)
  212.  
  213.            procedure NormalForm(I: integer);
  214.            var Show:                s2;
  215.                X,
  216.                Y:                  integer;
  217.            begin
  218.            str(I, Show);
  219.            SetXY(I,X,Y);
  220.            FastWrite( Show, Y, X, (Menus.Attr or $0008) );
  221.            FastWrite( Form[I].Description, Y, X+3, (Menus.Attr or $0008) );
  222.            end;
  223.  
  224.            (* -------------------------------------------------------------------- *)
  225.  
  226.           procedure ShowPlacement(UseForm: FormRecord);
  227.           var Show:                            S5;
  228.               J,
  229.               I:                               integer;
  230.           begin
  231.           ColorIn( 1, 1, 80, LastDescription, Inputs.Attr);
  232.           for I := 1 to LastDescription do
  233.               begin
  234.               FastWrite( BlankLine, I, 1, (Inputs.Attr or $0008) );
  235.               str(I,Show);
  236.               FastWrite( Show, I, 1, (Inputs.Attr or $0008) );
  237.               for J := 1 to MaxFieldLine do
  238.                   if UseForm.PlaceArray[I,J] <> 0 then
  239.                      FastWrite( A[UseForm.PlaceArray[I,J]], I, J*6,
  240.                                SetAttr(false,false,Inputs.BG,Inputs.FG));
  241.               end;
  242.           end;
  243.  
  244.           procedure EditForm(Choice: integer);
  245.           var Continue,
  246.               FunctionKey:                    boolean;
  247.               Ch:                             char;
  248.               OCh:                            integer;
  249.  
  250.              procedure ShowForm(UseForm: FormRecord);
  251.              var Show:                           S5;
  252.              begin
  253.              clrscr;
  254.              ShowPlacement(UseForm);
  255.              with UseForm do
  256.                 begin
  257.                 DrawSquare( 1, LastDescription+1, 80, 25, Msgs.Attr, true);
  258.                 FastWrite( LPad('F1 '+Description,33),
  259.                            LastDescription+3, 5, Msgs.Attr);
  260.                 str(ReturnColOffset,Show);
  261.                 FastWrite( 'F2 Return Column               '+Show,
  262.                           LastDescription+4, 5, Msgs.Attr);
  263.                 str(ReturnRowOffset,Show);
  264.                 FastWrite( 'F3 Return Row                  '+Show,
  265.                           LastDescription+5, 5, Msgs.Attr);
  266.                 str(ColOffset,Show);
  267.                 FastWrite( 'F4 Address Column              '+Show,
  268.                           LastDescription+6, 5, Msgs.Attr);
  269.                 str(RowOffset,Show);
  270.                 FastWrite( 'F5 Address Row                 '+Show,
  271.                           LastDescription+7, 5, Msgs.Attr);
  272.                 str(FormLen,Show);
  273.                 FastWrite( 'F6 Form length (top-to-bottom) '+Show,
  274.                           LastDescription+8, 5, Msgs.Attr);
  275.                 str(FormWidth,Show);
  276.                 FastWrite( 'F7 Form width (side-to-side)   '+Show,
  277.                           LastDescription+9, 5, Msgs.Attr);
  278.                 FastWrite( 'F8 Field Placement             ',
  279.                           LastDescription+10, 5, Msgs.Attr);
  280.                 FastWrite( '[ESC]',
  281.                           LastDescription+11, 5, Msgs.Attr);
  282.  
  283.                 FastWrite( 'Warning !', LastDescription+5, 45,
  284.                            (Msgs.Attr or $0008));
  285.                 FastWrite( 'Both Row and Column must be', LastDescription+6,
  286.                            45, Msgs.Attr);
  287.                 FastWrite( 'greater than zero to print.', LastDescription+7,
  288.                            45, Msgs.Attr);
  289.                 end;
  290.              end;
  291.  
  292.              procedure EnterFormField( var UseForm: FormRecord;
  293.                                            Field:   integer);
  294.              var Err,
  295.                  Num,
  296.                  X,
  297.                  AllowControl,
  298.                  Y:                                integer;
  299.                  Entry:                            string;
  300.                  Temp:                             s40;
  301.                  AllowInput:                       boolean;
  302.              begin
  303.              X := 5;   Y := 24;
  304.              AllowControl := -1;
  305.              AllowInput := true;
  306.              with UseForm do
  307.                 begin
  308.                 case Field of
  309.                    1:  begin
  310.                        Entry := '';
  311.                        Temp := 'Enter new description.';
  312.                        FastWrite( Temp, Y, X, Inputs.Attr);
  313.                        Entry := GetForm( X+35, Y, 30, Strng(30,#32),
  314.                                          Description, AllowControl,
  315.                                          AllowInput, Inputs.Attr,
  316.                                          [#31..#126]);
  317.                        FastWrite( Strng(65,#32), Y, X, Displays.Attr);
  318.                        if Strip(Entry) <> '' then Description := Entry;
  319.                        end;
  320.                    2:  begin
  321.                        Num := 0;
  322.                        Temp := 'Return Column position';
  323.                        FastWrite( Temp, Y, X, Inputs.Attr);
  324.                        Num := Str2Int( GetForm( X+35, Y, 3, '   ',
  325.                                                 Real2Str(ReturnColOffset,3,0),
  326.                                                 AllowControl, AllowInput,
  327.                                                 Inputs.Attr,['0'..'9']),
  328.                                         Err);
  329.                        FastWrite( Strng(50,#32), Y, X, Displays.Attr);
  330.                        if Err = 0 then ReturnColOffset := Num;
  331.                        end;
  332.                    3:  begin
  333.                        Num := 0;
  334.                        Temp := 'Return Row position';
  335.                        FastWrite( Temp, Y, X, Inputs.Attr);
  336.                        Num := Str2Int( GetForm( X+35, Y, 3, '   ',
  337.                                                 Real2Str(ReturnRowOffset,3,0),
  338.                                                 AllowControl, AllowInput,
  339.                                                 Inputs.Attr,['0'..'9']),
  340.                                         Err);
  341.                        FastWrite( Strng(50,#32), Y, X, Displays.Attr);
  342.                        if Err = 0 then ReturnRowOffset := Num;
  343.                        end;
  344.                    4:  begin
  345.                        Num := 0;
  346.                        Temp := 'Address Column position';
  347.                        FastWrite( Temp, Y, X, Inputs.Attr);
  348.                        Num := Str2Int( GetForm( X+35, Y, 3, '   ',
  349.                                                 Real2Str(ColOffset,3,0),
  350.                                                 AllowControl, AllowInput,
  351.                                                 Inputs.Attr,['0'..'9']),
  352.                                         Err);
  353.                        FastWrite( Strng(50,#32), Y, X, Displays.Attr);
  354.                        if Err = 0 then ColOffset := Num;
  355.                        end;
  356.                    5:  begin
  357.                        Num := 0;
  358.                        Temp := 'Address Row position';
  359.                        FastWrite( Temp, Y, X, Inputs.Attr);
  360.                        Num := Str2Int( GetForm( X+35, Y, 3, '   ',
  361.                                                 Real2Str(RowOffset,3,0),
  362.                                                 AllowControl, AllowInput,
  363.                                                 Inputs.Attr,['0'..'9']),
  364.                                         Err);
  365.                        FastWrite( Strng(50,#32), Y, X, Displays.Attr);
  366.                        if Err = 0 then RowOffset := Num;
  367.                        end;
  368.                    6:  begin
  369.                        Num := 0;
  370.                        Temp := 'Form length (top to bottom)';
  371.                        FastWrite( Temp, Y, X, Inputs.Attr);
  372.                        Num := Str2Int( GetForm( X+35, Y, 3, '   ',
  373.                                                 Real2Str(FormLen,3,0),
  374.                                                 AllowControl, AllowInput,
  375.                                                 Inputs.Attr,['0'..'9']),
  376.                                         Err);
  377.                        FastWrite( Strng(50,#32), Y, X, Displays.Attr);
  378.                        if Err = 0 then FormLen := Num;
  379.                        end;
  380.                    7:  begin
  381.                        Num := 0;
  382.                        Temp := 'Form width (side to side)';
  383.                        FastWrite( Temp, Y, X, Inputs.Attr);
  384.                        Num := Str2Int( GetForm( X+35, Y, 3, '   ',
  385.                                                 Real2Str(FormWidth,3,0),
  386.                                                 AllowControl, AllowInput,
  387.                                                 Inputs.Attr,['0'..'9']),
  388.                                         Err);
  389.                        FastWrite( Strng(50,#32), Y, X, Displays.Attr);
  390.                        if Err = 0 then FormWidth := Num;
  391.                        end;
  392.                    end;
  393.                 end;
  394.              end;
  395.  
  396.              procedure FieldPlacement( var UseForm: FormRecord);
  397.              var Continue:                      boolean;
  398.                  Place,
  399.                  Num,
  400.                  I,
  401.                  J,
  402.                  Row:                           integer;
  403.  
  404.                 procedure Choices(UseForm: FormRecord);
  405.                 var I:                           integer;
  406.                     TempStr:                     S80;
  407.                 begin
  408.                 ShowPlacement(UseForm);
  409.                 for I := LastDescription+3 to (LastDescription + (LastDescription div 2) + 4) do
  410.                     FastWrite( BlankLine, I, 1, Msgs.Attr);
  411.                 DrawSquare( 1, 22, 80, 25, Menus.Attr, true);
  412.                 TempStr := 'INS (front)    + (insert end)    DEL (front)    BKSPC (end)';
  413.                 FastWrite( CPad(TempStr,78), 23, 2, Menus.Attr);
  414.                 TempStr := 'F5 (insert line)    F9 (delete line)    [ESC]';
  415.                 FastWrite( CPad(TempStr,78), 24, 2, Menus.Attr);
  416.                 end;
  417.  
  418.                 function FindLastField( Row:     integer;
  419.                                         UseForm: FormRecord): integer;
  420.                 var Temp:                        integer;
  421.                 begin
  422.                 Temp := 1;
  423.                 if UseForm.PlaceArray[Row,MaxFieldLine] <> 0 then
  424.                    FindLastField := MaxFieldLine
  425.                   else
  426.                    if UseForm.PlaceArray[Row,1] = 0 then
  427.                       FindLastField := 0
  428.                      else
  429.                       begin
  430.                       while UseForm.PlaceArray[Row,Temp] <> 0 do inc(Temp);
  431.                       FindLastField := pred(Temp);
  432.                       end;
  433.                 end;
  434.  
  435.                 procedure InsertWhich(var X:integer);
  436.                 var OCh,
  437.                     I:                     integer;
  438.                     FunctionKey,
  439.                     Continue:              boolean;
  440.                     Ch:                    char;
  441.                 begin
  442.                 Continue := true;
  443.                 for I := 22 to 25 do
  444.                     FastWrite(BlankLine, I, 1, Displays.Attr);
  445.                 while Continue do
  446.                    begin
  447.                    for I := 1 to LastDescription div 2 do
  448.                        FastWrite( chr(I+64)+' '+Description[I],
  449.                                  LastDescription+2+I, 1, Menus.Attr);
  450.                    for I := LastDescription div 2 + 1 to LastDescription do
  451.                        FastWrite( chr(I+64)+' '+Description[I],
  452.                                  LastDescription+2+I-(LastDescription div 2),
  453.                                  41, Menus.Attr);
  454.                    FastWrite( 'Letter or [ESC] to exit',
  455.                              LastDescription+2+(LastDescription div 2) + 2,
  456.                              1, Menus.Attr);
  457.                    GetKey(Ch,FunctionKey);
  458.                    Ch := upcase(Ch);
  459.                    OCh := ord(Ch);
  460.                    if OCh = 27 then
  461.                       begin
  462.                       X := 0;
  463.                       Continue := false;
  464.                       end
  465.                      else
  466.                       begin
  467.                       if (OCh-64>0) and (OCh-64<=LastDescription) then
  468.                          begin
  469.                          X := OCh-64;
  470.                          Continue := false;
  471.                          end
  472.                         else
  473.                          begin
  474.                          Beep(1);
  475.                          end;
  476.                       end;
  477.                    end;
  478.                 end;
  479.  
  480.              begin          (* FieldPlacement(UseForm) *)
  481.              clrscr;
  482.              CursorOn(false);
  483.              Choices(UseForm);
  484.              Continue := true;
  485.              Row := 1;
  486.              while Continue do
  487.                 begin
  488.                 FastWrite( chr(16), Row, 4, Headings.Attr);
  489.                 GetKey(Ch,FunctionKey);
  490.                 OCh := ord(Ch);
  491.                 if OCh = 27 then Continue := false;
  492.                 FunctionKey := true;
  493.                 if FunctionKey then
  494.                    begin
  495.                    case OCh of
  496.                       72:  begin
  497.                            FastWrite( ' ', Row, 4, Inputs.Attr);
  498.                            if Row > 1 then dec(Row);
  499.                            end;
  500.                       80:  begin
  501.                            FastWrite( ' ', Row, 4, Inputs.Attr);
  502.                            if Row < LastDescription then inc(Row);
  503.                            end;
  504.                       63:  begin               (* f5 = insert line *)
  505.                            if Row <> LastDescription then
  506.                               for I := LastDescription downto succ(Row) do
  507.                                   for J := 1 to MaxFieldLine do
  508.                                       UseForm.PlaceArray[I,J] := UseForm.PlaceArray[pred(I),J];
  509.                            for J := 1 to MaxFieldLine do
  510.                                UseForm.PlaceArray[Row,J] := 0;
  511.                            Choices(UseForm);
  512.                            end;
  513.                       67:  begin               (* f9 = delete S80 *)
  514.                            for I := Row to pred(LastDescription)  do
  515.                                for J := 1 to MaxFieldLine do
  516.                                    UseForm.PlaceArray[I,J] := UseForm.PlaceArray[succ(I),J];
  517.                            for J := 1 to MaxFieldLine do
  518.                                UseForm.PlaceArray[LastDescription,J] := 0;
  519.                            Choices(UseForm);
  520.                            end;
  521.                       48,
  522.                       43:  begin          (* ins @ end *)
  523.                            Place := FindLastField(Row,UseForm);
  524.                            if Place <> MaxFieldLine then
  525.                               begin
  526.                               gotoxy(1,23);   clreol;
  527.                               InsertWhich(Num);
  528.                               if Num <> 0 then
  529.                                  begin
  530.                                  UseForm.PlaceArray[Row,succ(Place)] := Num;
  531.                                  end;
  532.                               end;
  533.                            Choices(UseForm);
  534.                            end;
  535.                       82:  begin          (* ins @ front *)
  536.                            Place := FindLastField(Row,UseForm);
  537.                            if Place <> MaxFieldLine then
  538.                               begin
  539.                               gotoxy(1,23);   clreol;
  540.                               InsertWhich(Num);
  541.                               if Num <> 0 then
  542.                                  begin
  543.                                  for I := MaxFieldLine downto 2 do
  544.                                      UseForm.PlaceArray[Row,I] := UseForm.PlaceArray[Row,pred(I)];
  545.                                  UseForm.PlaceArray[Row,1] := Num;
  546.                                  end;
  547.                               end;
  548.                            Choices(UseForm);
  549.                            end;
  550.                       83,
  551.                       32:  begin       (* del @ front; also <alt d> *)
  552.                            for I := 1 to pred(MaxFieldLine) do
  553.                                UseForm.PlaceArray[Row,I] := UseForm.PlaceArray[Row,succ(I)];
  554.                            UseForm.PlaceArray[Row,MaxFieldLine] := 0;
  555.                            Choices(UseForm);
  556.                            end;
  557.                       8:   begin          (* bkspc @ end *)
  558.                            Place := FindLastField(Row,UseForm);
  559.                            UseForm.PlaceArray[Row,Place] := 0;
  560.                            Choices(UseForm);
  561.                            end;
  562.                       end;   (* case *)
  563.                    end;  (* if..then *)
  564.                 end;
  565.              end;
  566.  
  567.           begin   (* EditForm(Choice) *)
  568.           ShowForm(Form[Choice]);
  569.           Continue := true;
  570.           while Continue do
  571.              begin
  572.              CursorOn(false);
  573.              GetKey(Ch,FunctionKey);
  574.              OCh := ord(Ch);
  575.              if OCh = 27 then Continue := false;
  576.              if FunctionKey then
  577.                 begin
  578.                 case OCh of
  579.                    59..65: begin
  580.                         EnterFormField(Form[Choice],OCh-58);
  581.                         ShowForm(Form[Choice]);
  582.                         end;
  583.                    66:  begin
  584.                         FieldPlacement(Form[Choice]);
  585.                         ShowForm(Form[Choice]);
  586.                         end;
  587.                    end;
  588.                 end;  (* if..then *)
  589.              end;
  590.           clrscr;
  591.           end;
  592.  
  593.        begin         (* SetForms *)
  594.        ReadForms;
  595.        FormsDisplay;
  596.        Temp := ActiveForm;
  597.        SetHeadings;
  598.        AltAttr := SetAttr(false, false, Menus.BG, Menus.FG);
  599.        if ProgramUse = 2 then
  600.           begin
  601.           A[1] := 'COMP.';
  602.           A[3] := 'NAME ';
  603.           end;
  604.        Choice := 1;
  605.        if Temp <> 0 then Choice := Temp;
  606.        ActiveForm := 0;
  607.        Continue := true;
  608.        while Continue do
  609.           begin
  610.           HighLightForm(Choice);
  611.           GetKey(Ch,FunctionKey);
  612.           NormalForm(Choice);
  613.           OCh := ord(Ch);
  614.           if FunctionKey then
  615.              begin
  616.              case OCh of
  617.                  60: begin                             (* f2 = choose *)
  618.                      ActiveForm := Choice;
  619.                      PutMode(ShowMode,PrinterMode);
  620.                      Continue := false;
  621.                      end;
  622.                  62: begin
  623.                      EditForm(Choice);                (* f4 = edit *)
  624.                      FormsDisplay;
  625.                      end;
  626.                  77: if (Choice+20) < 41 then
  627.                         Choice := Choice + 20;         (* rarr *)
  628.                  75: if (Choice-20) > 0 then
  629.                         Choice := Choice - 20;         (* larr *)
  630.                  80: if ((Choice-1) mod 20)+1 < 20 then
  631.                         inc(Choice);                   (* darr *)
  632.                  72: if ((Choice-1) mod 20)+1 > 1 then
  633.                         dec(Choice);                   (* uarr *)
  634.                  end;    (* end of case statement *)
  635.              end
  636.             else
  637.              if OCh = 27 then Continue := false;
  638.           end;     (* end while loop *)
  639.        clrscr;
  640.        WriteForms;
  641.        end;
  642.  
  643.        (* ---------------- *)
  644.  
  645.        procedure WhichPrinter(var ActivePrinter: integer);
  646.        var OCh,
  647.            Which,
  648.            Choice,
  649.            I:            integer;
  650.            FunctionKey,
  651.            Continue:     boolean;
  652.            Ch:           char;
  653.            TempStr:      S80;
  654.            AltAttr:          byte;
  655.  
  656.            (* ---------------- *)
  657.  
  658.            procedure PrinterCodes(TempPrinter: integer);
  659.            var AllowInput,
  660.                Continue:      boolean;
  661.                Show:          s10;
  662.                Err,
  663.                AllowControl:  integer;
  664.            begin
  665.            clrscr;
  666.            Continue := true;
  667.            AllowControl := -1;
  668.            AllowInput := true;
  669.            FastWrite( CPad(Printers[TempPrinter],72), 15, 5,
  670.                      (Menus.Attr or $0008));
  671.            while Continue do
  672.               begin
  673.               DrawSquare(1,1,80,10,Inputs.Attr,true);
  674.  
  675.               str(Compress1[TempPrinter],Show);
  676.               FastWrite( 'First Compression code     '+Show, 3, 5, Inputs.Attr);
  677.               Compress1[TempPrinter] :=
  678.                         Str2Int( GetForm( 35, 3, 3, '   ', Show, AllowControl,
  679.                                           AllowInput, Inputs.Attr, ['0'..'9']),
  680.                                  Err);
  681.  
  682.               str(Compress2[TempPrinter],Show);
  683.               FastWrite( 'Second Compression code    '+Show, 4, 5, Inputs.Attr);
  684.               Compress2[TempPrinter] :=
  685.                         Str2Int( GetForm( 35, 4, 3, '   ', Show, AllowControl,
  686.                                           AllowInput, Inputs.Attr, ['0'..'9']),
  687.                                  Err);
  688.  
  689.               str(DeCompress1[TempPrinter],Show);
  690.               FastWrite( 'First De-Compression code  '+Show, 5, 5, Inputs.Attr);
  691.               DeCompress1[TempPrinter] :=
  692.                         Str2Int( GetForm( 35, 5, 3, '   ', Show, AllowControl,
  693.                                           AllowInput, Inputs.Attr, ['0'..'9']),
  694.                                  Err);
  695.  
  696.               str(DeCompress2[TempPrinter],Show);
  697.               FastWrite( 'Second De-Compression code '+Show, 6, 5, Inputs.Attr);
  698.               DeCompress2[TempPrinter] :=
  699.                         Str2Int( GetForm( 35, 6, 3, '   ', Show, AllowControl,
  700.                                           AllowInput, Inputs.Attr, ['0'..'9']),
  701.                                  Err);
  702.  
  703.               FastWrite( CPad('Correct ?   (Y/N)',78), 8, 2, Inputs.Attr);
  704.               GetKey(Ch,FunctionKey);
  705.               clrscr;
  706.               Ch := upcase(Ch);
  707.               if Ch='Y' then Continue := false;
  708.               end;
  709.            end;
  710.  
  711.            (* ---------------- *)
  712.  
  713.            procedure ShowPrinters;
  714.            var I:                  integer;
  715.                Show:                S80;
  716.            begin
  717.            clrscr;
  718.            DrawSquare( 1, 1, 80, 22, Displays.Attr, true);
  719.            Shadow( 3, 3, 76, MostPrinters+8, Menus.Attr, true);
  720.            for I := 1 to MostPrinters do
  721.                FastWrite( CPad((Printers[I]),72),
  722.                          I+6, 4, (Menus.Attr or $0008) );
  723.            DrawSquare( 1, 23, 80, 25, Msgs.Attr, true);
  724.            Show := 'F2 = Edit type   F4 = Edit codes  F10 = Select Printer';
  725.            FastWrite( CPad(Show,78), 24, 2, Msgs.Attr);
  726.            end;
  727.  
  728.            (* ---------------- *)
  729.  
  730.        begin
  731.        GetPrinters;
  732.        AltAttr := SetAttr(false, false, Menus.BG, Menus.FG);
  733.        Choice := ActivePrinter;
  734.        if (Choice < 1) or (Choice > MostPrinters) then Choice := 1;
  735.        Continue := true;
  736.        ShowPrinters;
  737.        while Continue do
  738.           begin
  739.           TempStr := 'Active Printer = ' + Printers[ActivePrinter];
  740.           FastWrite( CPad(TempStr,72), 5, 4, (Menus.Attr or $0008));
  741.           FastWrite( CPad((Printers[Choice]),72),
  742.                     Choice+6, 4, AltAttr );
  743.           GetKey(Ch,FunctionKey);
  744.           Ch := upcase(Ch);
  745.           OCh := ord(Ch);
  746.           FastWrite( CPad((Printers[Choice]),72),
  747.                     Choice+6, 4, (Menus.Attr or $0008) );
  748.           if FunctionKey then
  749.              begin
  750.              case OCh of
  751.                 80: if Choice < MostPrinters then
  752.                        inc(Choice);           (* darr *)
  753.                 72: if Choice > 1 then
  754.                        dec(Choice);           (* uarr *)
  755.                 68: begin
  756.                     ActivePrinter := Choice;
  757.                     clrscr;
  758.                     PutMode(ShowMode,PrinterMode);
  759.                     Continue := false;
  760.                     end;
  761.                 62: begin
  762.                     PrinterCodes(Choice);
  763.                     ShowPrinters;
  764.                     end;
  765.                 60: begin
  766.                     FastWrite( CPad((Printers[Choice]),72),
  767.                               Choice+6, 5, AltAttr );
  768.                     FastWrite( ' Printer description ?                     ',
  769.                               MostPrinters+10, 5, Inputs.Attr );
  770.                     gotoxy(30,MostPrinters+10);
  771.                     read(Printers[Choice]);
  772.                     ShowPrinters;
  773.                     end;
  774.                 end;   (* end case *)
  775.              end;
  776.           end;
  777.        PutPrinters;
  778.        end;
  779.  
  780.        (* ---------------- *)
  781.  
  782.     begin
  783.     Show[0] := 'SET PRINTER VALUES';
  784.     Show[1] := '1. Set single line Print Mode';
  785.     Show[2] := '2. Design and Select Printer Forms';
  786.     Show[3] := '3. Assign and Select Active Printer';
  787.     Show[4] := '9. Exit to Operations Menu';
  788.     while Ch <> #27 do
  789.       begin
  790.       Ch := RetMenu( Show, 4, FunctionKey);
  791.       case Ch of
  792.          '1': SetPrinterMode;
  793.          '2': SetForms;
  794.          '3': WhichPrinter(ActivePrinter);
  795.          '9': Ch := #27;
  796.          end;   (* case *)
  797.       end;        (* while *)
  798.     end;
  799.  
  800.     (* ------------------------------- *)
  801.  
  802.     procedure SystemValueSet;
  803.     var Col,
  804.         Row:                     integer;
  805.         FunctionKey:             boolean;
  806.         Ch:                      char;
  807.         Show:                    LineArray;
  808.  
  809.  
  810.            procedure UsageType;
  811.            var FunctionKey:        boolean;
  812.                Ch:                 char;
  813.                Show:               LineArray;
  814.            begin
  815.            clrscr;
  816.            Show[1] := CPad(
  817.            'You may select either the Commercial or Personal version',
  818.            60);
  819.            Show[2] := CPad(
  820.            'of MailPro. The only difference between the two versions',
  821.            60);
  822.            Show[3] := CPad(
  823.            'are the headings used.',
  824.            60);
  825.            for I := 1 to 3 do FastWrite( Show[I], I, 10, Msgs.Attr);
  826.  
  827.            Shadow( 10, 5, 70, 11, Headings.Attr, true);
  828.            Show[1]:=CPad('Personal                        Commercial    ',50);
  829.            Show[2]:=CPad('--------                        ----------    ',50);
  830.            Show[3]:=CPad('Addressee      (Field 1)        Company       ',50);
  831.            Show[4]:=CPad('Title          (Field 2)        Title         ',50);
  832.            Show[5]:=CPad('Company        (Field 3)        Contact person',50);
  833.            for I := 1 to 5 do FastWrite( Show[I], I+5, 15, Headings.Attr);
  834.  
  835.            Show[1] := CPad(
  836.            'When reading the instruction manual, if you have chosen',60);
  837.            Show[2] := CPad(
  838.            'the commercial version, substitute the appropriate headings.',60);
  839.            for I := 1 to 2 do FastWrite( Show[I], I+12, 10, Msgs.Attr);
  840.  
  841.            Show[1] := CPad('P = personal    or    C = commercial ? ',50);
  842.            FastWrite( Show[1], 16, 15, Inputs.Attr);
  843.            GetKey(Ch,FunctionKey);
  844.            Ch := upcase(Ch);
  845.            FastWrite( Ch, 17, 40, Inputs.Attr);
  846.            ProgramUse := 1;   (* defaults to personal mode *)
  847.            if Ch='C' then ProgramUse := 2;
  848.            PutMode(ShowMode,PrinterMode);
  849.            end;
  850.  
  851.            procedure BackupMenu;
  852.            var TempStr,
  853.                Response:           s30;
  854.                AllowControl:       integer;
  855.                AllowInput:         boolean;
  856.  
  857.                    procedure GetBackupFileTop;
  858.                    var Err:  integer;
  859.                        fial: string;
  860.                    begin
  861.                    fial := concat(DataDrive,'mailtop.bck');
  862.                    {$I-}
  863.                    assign(IntFile,fial);
  864.                    reset(IntFile);
  865.                    read(IntFile,BackupFileTop);
  866.                    read(IntFile,BackupSortTop);
  867.                    close(IntFile);
  868.                    {$I+}
  869.                    Err := ioresult;
  870.                    end;
  871.  
  872.                    procedure PutBackupFileTop;
  873.                    var Fial:                  string;
  874.                    begin
  875.                    fial := concat(DataDrive,'mailtop.bck');
  876.                    assign(IntFile,fial);
  877.                    rewrite(IntFile);
  878.                    write(IntFile,BackupFileTop);
  879.                    write(IntFile,BackupSortTop);
  880.                    close(IntFile);
  881.                    end;
  882.  
  883.                    procedure OpenBackupFile;
  884.                    var Err:  integer;
  885.                        Fial: string;
  886.                    begin
  887.                    Fial := concat(DataDrive,'maillist.bck');  {$I-}
  888.                    assign(TempMainFile,fial);
  889.                    reset(TempMainFile);                {$I+}
  890.                    Err := ioresult;
  891.                    if Err <> 0 then rewrite(TempMainFile);
  892.                    end;
  893.  
  894.                    procedure GetBackupRec(var Entry: MainRecordType;
  895.                                               Rec:   integer);
  896.                    var Err:  integer;
  897.                    begin                  {$I-}
  898.                    seek(TempMainFile,pred(Rec));
  899.                    read(TempMainFile,Entry);                {$I+}
  900.                    Err := ioresult;
  901.                    end;
  902.  
  903.                    procedure PutBackupRec( Entry: MainRecordType;
  904.                                            Rec:   integer);
  905.                    begin
  906.                    seek(TempMainFile,pred(Rec));
  907.                    write(TempMainFile,Entry);
  908.                    end;
  909.  
  910.                procedure Backup;
  911.                var I:            integer;
  912.                    TempStr:      s10;
  913.                begin
  914.                clrscr;
  915.                OpenBackupFile;
  916.                Shadow( 30, 10, 50, 15, Headings.Attr, true);
  917.                FastWrite('Backing up', 12, 35, Headings.Attr);
  918.                for I := 1 to FileTop do
  919.                    begin
  920.                    if (I mod 10) = 0 then
  921.                       begin
  922.                       str(I,TempStr);
  923.                       FastWrite( CPad(TempStr,10), 13, 35, Msgs.Attr);
  924.                       end;
  925.                    GetRec(Entry,I);
  926.                    PutBackupRec(Entry,I);
  927.                    end;
  928.                BackupFileTop := FileTop;
  929.                BackupSortTop := SortTop;
  930.                PutBackupFileTop;
  931.                seek(TempMainFile,FileTop);
  932.                truncate(TempMainFile);
  933.                close(TempMainFile);
  934.                end;
  935.  
  936.                procedure Restore;
  937.                var I:            integer;
  938.                    TempStr:      s30;
  939.                begin
  940.                clrscr;
  941.                OpenBackupFile;
  942.                Shadow( 30, 10, 50, 15, Headings.Attr,true);
  943.                FastWrite('Restoring ', 12, 35, Headings.Attr);
  944.                for I := 1 to FileTop do
  945.                    begin
  946.                    if (I mod 5) = 0 then
  947.                       begin
  948.                       str(I,TempStr);
  949.                       FastWrite( CPad(TempStr,10), 13, 35, Msgs.Attr);
  950.                       end;
  951.                    GetBackupRec(Entry,I);
  952.                    PutRec(Entry,I);
  953.                    end;
  954.                FileTop := BackupFileTop;
  955.                SortTop := BackupSortTop;
  956.                PutFileTop;
  957.                seek(AddressFile,FileTop);
  958.                truncate(AddressFile);
  959.                close(TempMainFile);
  960.                end;
  961.  
  962.            begin
  963.            clrscr;
  964.            AllowControl := -1;
  965.            AllowInput := true;
  966.            GetFileTop;
  967.            GetBackupFileTop;
  968.            DrawSquare( 1, 1, 80, 4, Msgs.Attr, true);
  969.  
  970.            str(FileTop:5, TempStr);
  971.            FastWrite( 'Main file top   '+TempStr, 2, 5, Msgs.Attr);
  972.            str(SortTop:5, TempStr);
  973.            FastWrite( 'Sorted '+ TempStr, 2, 41, Msgs.Attr);
  974.  
  975.            str(BackupFileTop:5, TempStr);
  976.            FastWrite( 'Backup file top '+TempStr, 3, 5, Msgs.Attr);
  977.            str(BackupSortTop:5, TempStr);
  978.            FastWrite( 'Sorted '+ TempStr, 3, 41, Msgs.Attr);
  979.  
  980.            FastWrite( CPad('Type "Restore", "Backup" or strike [ENTER]',50),
  981.                       6, 15, Inputs.Attr);
  982.            Response := GetForm( 35, 7, 10, Strng(10,#32), '', AllowControl,
  983.                                 AllowInput, (Inputs.Attr or $0008),
  984.                                 [#31..#126]);
  985.            if UCase(Response) = 'RESTORE' then
  986.               begin
  987.               Restore;
  988.               end
  989.              else
  990.               if UCase(Response) = 'BACKUP' then
  991.                  begin
  992.                  Backup;
  993.                  end;
  994.            end;
  995.  
  996.     begin
  997.     Show[0] := 'SYSTEM HANDLING';
  998.     Show[1] := '1. Backup and Restore';
  999.     Show[2] := '2. Set program type';
  1000.     Show[3] := '3. Set program colors';
  1001.     Show[4] := '4. Set top of file';
  1002.     while Ch <> #27 do
  1003.        begin
  1004.        Ch := RetMenu( Show, 4, FunctionKey);
  1005.        case Ch of
  1006.           '1':   BackupMenu;
  1007.           '2':   UsageType;
  1008.           '3':   ColorSet;
  1009.           '4':   SetTopOfFile;
  1010.           '9':   Ch := #27;
  1011.           end;
  1012.        end;
  1013.     end;
  1014.  
  1015.     (* ------------------------------- *)
  1016.  
  1017.     procedure Import;
  1018.     var  Fial,
  1019.          FileName:                        s80;
  1020.          OutPutFile,
  1021.          ImportFile:               file of MainRecordType;
  1022.          ImportTop,
  1023.          GetImport,
  1024.          AllowControl,
  1025.          GetActive,
  1026.          PutPoint,
  1027.          I,
  1028.          D,
  1029.          SD,
  1030.          Err:                       integer;
  1031.          TempStr:                   s10;
  1032.          AllowInput,
  1033.          NewCode:                  boolean;
  1034.          ImportEntry,
  1035.          ActiveEntry:                 MainRecordType;
  1036.  
  1037.           (* ------------------- *)
  1038.  
  1039.           procedure WriteNumbers( GetActive, GetImport, PutPoint: integer);
  1040.           var Num:                                             integer;
  1041.               TempStr:                                         s10;
  1042.           begin
  1043.           Num := 10;
  1044.           if (GetActive mod Num) = 0 then
  1045.              begin
  1046.              str(GetActive:5,TempStr);
  1047.              FastWrite( TempStr, 12, 41, Msgs.Attr);
  1048.              end;
  1049.           if (GetImport mod Num) = 0 then
  1050.              begin
  1051.              str(GetImport:5,TempStr);
  1052.              FastWrite( TempStr, 13, 41, Msgs.Attr);
  1053.              end;
  1054.           if (PutPoint mod Num) = 0 then
  1055.              begin
  1056.              str(PutPoint:5,TempStr);
  1057.              FastWrite( TempStr, 14, 41, Msgs.Attr);
  1058.              end;
  1059.           end;
  1060.  
  1061.           (* ------------------- *)
  1062.  
  1063.           procedure ChooseDivision(var Division, SubDivision: integer);
  1064.           var Continue,
  1065.               ChangeMade:            boolean;
  1066.               TempNum:                integer;
  1067.               Temp:              s30;
  1068.  
  1069.              (* ------------------- *)
  1070.  
  1071.              procedure ChooseSubDivision( Division: integer;
  1072.                                           var SubDivision: integer);
  1073.              var FunctionKey,
  1074.                  Continue:                 boolean;
  1075.                  Ch:                       char;
  1076.                  TempNum:                       integer;
  1077.                  Temp:                     s30;
  1078.  
  1079.                 (* ----- *)
  1080.  
  1081.                 procedure LocalPrintSubDivision(Division: integer);
  1082.                 var I:integer;
  1083.                 begin
  1084.                 clrscr;
  1085.                 FastWrite(CPad('Division '+AlphaCode[Division,0],50), 1, 15, Headings.Attr);
  1086.                 for I := 1 to (SubDivisionTop div 2) do
  1087.                     begin
  1088.                     FastWrite( chr(I+64)+'  '+AlphaCode[Division,I], I+2, 1, Inputs.Attr);
  1089.                     FastWrite( chr(I+64+13)+'  '+AlphaCode[Division,I+13], I+2, 41, Inputs.Attr);
  1090.                     end;
  1091.                 DrawSquare( 1, 23, 80, 25, Menus.Attr, true);
  1092.                 FastWrite( CPad('Letter to assign',78), 24, 2, Menus.Attr);
  1093.                 end;
  1094.  
  1095.  
  1096.                 (* ----- *)
  1097.  
  1098.              begin
  1099.              Continue := true;
  1100.              while Continue do
  1101.                 begin
  1102.                 LocalPrintSubDivision(Division);
  1103.                 GetKey(Ch,FunctionKey);
  1104.                 Ch := upcase(Ch);
  1105.                 if (Ch > #64) and (Ch < #91) then TempNum := ord(ch) - 64;
  1106.                 case TempNum of
  1107.                     1..SubDivisionTop: begin
  1108.                                    SubDivision := TempNum;
  1109.                                    Continue := false;
  1110.                                    end;
  1111.                     end;        (* case *)
  1112.                 end;            (* while *)
  1113.              end;
  1114.  
  1115.              (* ------------------- *)
  1116.  
  1117.               procedure LocalPrintDivision;
  1118.               var I:integer;
  1119.               begin
  1120.               clrscr;
  1121.               FastWrite( CPad('Main Division Menu',80), 1, 1, Headings.Attr);
  1122.               for I := 1 to (DivisionTop div 2) do
  1123.                   begin
  1124.                   FastWrite( chr(64+I)+'  '+AlphaCode[I,0], I+2, 1, Inputs.Attr);
  1125.                   FastWrite( chr(64+I+13)+'  '+AlphaCode[I+13,0], I+2, 41, Inputs.Attr);
  1126.                   end;
  1127.               DrawSquare( 1, 23, 80, 25, Menus.Attr, true);
  1128.               FastWrite( CPad('Letter to assign',78), 24, 2, Menus.Attr);
  1129.               end;
  1130.  
  1131.  
  1132.              (* ------------------- *)
  1133.  
  1134.           begin
  1135.           Continue := true;
  1136.           ChangeMade := false;
  1137.           while Continue do
  1138.              begin
  1139.              LocalPrintDivision;
  1140.              GetKey(Ch,FunctionKey);
  1141.              Ch := upcase(Ch);
  1142.              TempNum := ord(Ch);
  1143.              if TempNum = 27 then
  1144.                 TempNum := 0
  1145.                else
  1146.                 if (Ch > #64) and (Ch < #91) then TempNum := TempNum - 64;
  1147.              case TempNum of
  1148.                 0:          Continue := false;
  1149.                 1..DivisionTop: begin
  1150.                             Division := TempNum;
  1151.                             ChooseSubDivision(TempNum,SubDivision);
  1152.                             Continue := false;
  1153.                             end;
  1154.                 end;         (* case *)
  1155.              end;            (* while *)
  1156.           end;
  1157.  
  1158.        (* ------------------------------------ *)
  1159.  
  1160.     begin
  1161.     AllowControl := -1;
  1162.     AllowInput := true;
  1163.     FastWrite( 'Enter merge file drive and/or directory  or "END".', 1, 1, Inputs.Attr);
  1164.     FileName := GetForm( 1, 2, 80, Strng(80,#32), '', AllowControl,
  1165.                          AllowInput, (Inputs.Attr or $0008),
  1166.                          ['A'..'Z','a'..'z','0'..'9','_','.','\',':']);
  1167.     if (UCase(Strip(FileName)) <> 'END') and (SortTop = FileTop)
  1168.                                          and (AllowControl <> -27) then
  1169.        begin
  1170.        fial := FileName + '\maillist';
  1171.        assign(ImportFile,fial);
  1172.        {$I-}   reset(ImportFile);
  1173.        {$I+}   Err := ioresult;
  1174.        if Err <> 0 then
  1175.           begin
  1176.           FastWrite( 'Invalid name !!!', 4, 1, Msgs.Attr);
  1177.           beep(1);
  1178.           {$I-}   close(ImportFile);
  1179.           {$I+}   Err := ioresult;
  1180.           Import;
  1181.           end
  1182.          else
  1183.           begin
  1184.           SetBG;
  1185.           clrscr;
  1186.           Ch := ' ';
  1187.           FastWrite( CPad(
  1188.           'Do you wish to set all incoming records to a specific code ?',80),
  1189.           1, 1, Inputs.Attr);
  1190.           while not (Ch in ['Y','N']) do
  1191.              begin
  1192.              Ch := upcase(ReturnKey(FunctionKey));
  1193.              end;
  1194.           if Ch = 'Y' then NewCode := true else NewCode := false;
  1195.           D := 0;     SD := 0;
  1196.           if NewCode then ChooseDivision(D,SD);
  1197.           SetBG;
  1198.           clrscr;
  1199.           CursorOn(false);
  1200.           assign(OutPutFile,DataDrive+'templist');
  1201.           rewrite(OutPutFile);
  1202.           ImportTop := filesize(ImportFile);
  1203.           Shadow( 15, 10, 65, 16, Headings.Attr, true);
  1204.  
  1205.           FastWrite( 'From Active list', 12, 21, Headings.Attr);
  1206.           str(FileTop:5,TempStr);
  1207.           FastWrite( 'of '+TempStr, 12, 51, Headings.Attr);
  1208.  
  1209.           FastWrite( 'From Import list', 13, 21, Headings.Attr);
  1210.           str(ImportTop:5,TempStr);
  1211.           FastWrite( 'of '+TempStr, 13, 51, Headings.Attr);
  1212.  
  1213.           FastWrite('Writing to record', 14, 21, Headings.Attr);
  1214.  
  1215.           GetActive := 1;   GetImport := 1;   PutPoint := 0;
  1216.           seek(ImportFile,pred(GetImport));
  1217.           read(ImportFile,ImportEntry);
  1218.           if NewCode then
  1219.              begin
  1220.              ImportEntry.Division := chr(D);
  1221.              ImportEntry.SubDivision := chr(SD);
  1222.              end;
  1223.           GetRec(ActiveEntry,GetActive);
  1224.           WriteNumbers(GetActive,GetImport,PutPoint);
  1225.           while (GetActive <= FileTop) or (GetImport <= ImportTop) do
  1226.              begin
  1227.              if GetActive > FileTop then
  1228.                 begin
  1229.                 inc(PutPoint);
  1230.                 seek(OutPutFile, pred(PutPoint));
  1231.                 write(OutPutFile,ImportEntry);
  1232.                 inc(GetImport);
  1233.                 if GetImport <= ImportTop then
  1234.                    begin
  1235.                    seek(ImportFile,pred(GetImport));
  1236.                    read(ImportFile,ImportEntry);
  1237.                    if NewCode then
  1238.                       begin
  1239.                       ImportEntry.Division := chr(D);
  1240.                       ImportEntry.SubDivision := chr(SD);
  1241.                       end;
  1242.                    end;
  1243.                 WriteNumbers(GetActive,GetImport,PutPoint);
  1244.                 end
  1245.                else               (* GetActive <= FileTop *)
  1246.                 begin
  1247.                 if GetImport > ImportTop then
  1248.                    begin
  1249.                    inc(PutPoint);
  1250.                    seek(OutPutFile,pred(PutPoint));
  1251.                    write(OutPutFile,ActiveEntry);
  1252.                    inc(GetActive);
  1253.                    if GetActive <= FileTop then
  1254.                       GetRec(ActiveEntry,GetActive);
  1255.                    WriteNumbers(GetActive,GetImport,PutPoint);
  1256.                    end
  1257.                   else
  1258.                    begin                          (* both still available *)
  1259.                    if UCase(Strip(ActiveEntry.Addressee))
  1260.                    <= UCase(Strip(ImportEntry.Addressee)) then
  1261.                       begin
  1262.                       inc(PutPoint);
  1263.                       seek(OutPutFile,pred(PutPoint));
  1264.                       write(OutPutFile,ActiveEntry);
  1265.                       inc(GetActive);
  1266.                       if GetActive <= FileTop then
  1267.                          GetRec(ActiveEntry,GetActive);
  1268.                       WriteNumbers(GetActive,GetImport,PutPoint);
  1269.                       end
  1270.                      else
  1271.                       begin
  1272.                       inc(PutPoint);
  1273.                       seek(OutPutFile,pred(PutPoint));
  1274.                       write(OutPutFile,ImportEntry);
  1275.                       inc(GetImport);
  1276.                       if GetImport <= ImportTop then
  1277.                          begin
  1278.                          seek(ImportFile,pred(GetImport));
  1279.                          read(ImportFile,ImportEntry);
  1280.                          if NewCode then
  1281.                             begin
  1282.                             ImportEntry.Division := chr(D);
  1283.                             ImportEntry.SubDivision := chr(SD);
  1284.                             end;
  1285.                          end;
  1286.                       WriteNumbers(GetActive,GetImport,PutPoint);
  1287.                       end;
  1288.                    end;
  1289.                 end;
  1290.              end;
  1291.  
  1292.           {$I-} close(ImportFile);    {$I+} Err := ioresult;
  1293.           {$I-} close(OutPutFile);    {$I+} Err := ioresult;
  1294.           {$I-} close(AddressFile);   {$I+} Err := ioresult;
  1295.  
  1296.           ReNameFile( DataDrive+'MailList', DataDrive+'OldList');
  1297.           ReNameFile( DataDrive+'TempList', DataDrive+'MailList');
  1298.           ReNameFile( DataDrive+'MailTop', DataDrive+'OldTop');
  1299.  
  1300.           FileTop := PutPoint;
  1301.           SortTop := FileTop;
  1302.           PutFileTop;
  1303.  
  1304.           DeleteFile(DataDrive+'OldList');
  1305.           DeleteFile(DataDrive+'OldTop');
  1306.  
  1307.           fial := DataDrive + 'maillist';
  1308.           assign(AddressFile,fial);
  1309.           reset(AddressFile);
  1310.           CursorOn(false);
  1311.  
  1312.           end;
  1313.        end
  1314.        else
  1315.        begin
  1316.        if FileTop <> SortTop then
  1317.           begin
  1318.           SetBG;
  1319.           clrscr;
  1320.           Shadow( 15, 10, 65, 15, Msgs.Attr, true);
  1321.           FastWrite( CPad('Main file must be sorted before   ',40), 12, 20, Msgs.Attr);
  1322.           FastWrite( CPad('additional files may be imported !',40), 13, 20, Msgs.Attr);
  1323.           FastWrite( 'Hit any key to continue.', 17, 28, Inputs.Attr);
  1324.           beep(1);
  1325.           while not keypressed do begin end;
  1326.           end;
  1327.        end;
  1328.     end;
  1329.  
  1330.     (* ------------------------------- *)
  1331.  
  1332. begin
  1333. Continue := true;
  1334. Show[0] := 'SYSTEM PARAMETER MENU';
  1335. Show[1] := '1. Set display mode';
  1336. Show[2] := '2. Set printer values';
  1337. Show[3] := '3. System handling';
  1338. Show[4] := '4. Import maillist';
  1339. Show[5] := '9. EXIT system menu';
  1340. while Ch <> #27 do
  1341.    begin
  1342.    Ch := RetMenu( Show, 5, FunctionKey);
  1343.    case Ch of
  1344.       '1': DisplayMode;
  1345.       '2': PrintMenu;
  1346.       '3': SystemValueSet;
  1347.       '4': begin
  1348.            clrscr;
  1349.            Import;
  1350.            end;
  1351.       '9': Ch := #27;
  1352.       end;
  1353.    end;
  1354. clrscr;
  1355. end;
  1356.  
  1357. end.
  1358. 
  1359.