home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / OBJTBA.ZIP / MMGRRPTS.DOC < prev    next >
Encoding:
Text File  |  1993-01-04  |  42.4 KB  |  1,339 lines

  1.    
  2.    
  3.                                         MMGRRPTS.PAS LISTING  PAGE  1    
  4.    
  5.    
  6.    UNIT MMgrRpts;
  7.    { This unit is the Report generation Unit that supports MMGR.PAS.
  8.      It exists to modularize the program and allow for main program
  9.      code of more than the 65K limit imposed by the TP IDE editor.
  10.      It utilizes routines from both ObjectBase and ObjectInterFace to
  11.      generate the reports and interact with the user.                  }
  12.    
  13.    INTERFACE
  14.    
  15.    USES Dos,
  16.         Crt,
  17.         Utility,     { ObjectInterFace - Various general purpose routines }
  18.                      {                   and interfaces to help system    }
  19.         MMgrVar,     { Global Variable declarations for MMGR.PAS          }
  20.         Forms,       { ObjectInterFace - Form Object Definition           }
  21.         Fields,      { ObjectInterFace - Field Object Definitions         }
  22.         Windows,     { ObjectInterFace - Windows and Menu Definitions     }
  23.         UserIO,      { ObjectInterFace - General User Input Output routines }
  24.         DBObjt,      { ObjectBase      - Lowleve File routines for use by }
  25.                      {                   OopBase Unit                     }
  26.         OopBase;     { ObjectBase      - Contains DB Object Definitions   }
  27.    
  28.    Procedure MailLabels;
  29.    Procedure ContactReports;
  30.    Procedure CompanyReports;
  31.    
  32.    IMPLEMENTATION
  33.    
  34.    function checkforprinter:boolean;
  35.    {  This routine is here for your use.  It informs the user if his printer
  36.       is not contected to the computer or is turned off.  EPSON Specific.   }
  37.    var rgs : registers;
  38.    begin
  39.      with rgs do
  40.      begin
  41.        AX := $0200;
  42.        DX := $0000;
  43.      end;
  44.      intr($17,Rgs);
  45.      CheckForPrinter := not ((Rgs.AH and $C8 = $C8) or (Rgs.AH and $30 = $30));
  46.    end;
  47.    
  48.    Procedure MailLabels;
  49.    var ch : char;  { Dummy variable to receive a keypress so it will be removed
  50.                      from keyboard buffer. }
  51.    
  52.      Procedure ContLabel;
  53.      { Handles Person Based Label generation }
  54.      label NoPrint;
  55.    
  56.      var OldDataFile,
  57.          OldNdxFile,
  58.          FileName: FName;
  59.          LabelDefaults : Form;
  60.          LftMrgn,
  61.          RghtMrgn,
  62.    
  63.    
  64.                                         MMGRRPTS.PAS LISTING  PAGE  2    
  65.    
  66.    
  67.          TopMrgn,
  68.          FilterCode,
  69.          PageLength : integer;
  70.          Device: text;
  71.          Tfile: oopfile;
  72.          truncate : Boolean;
  73.          ch : char;
  74.    
  75.         function PassesFilter(c : PersonType; code: integer): Boolean;
  76.         { simple filter routine for Person based label routine }
  77.    
  78.         var passed : Boolean;  { temparary variable }
  79.    
  80.         begin
  81.           Passed := true;
  82.           Case Code of
  83.             2 : begin    { flagged records only }
  84.                   passed := c.flag;
  85.                 end;
  86.             3 : begin    { unflagged records only }
  87.                   passed := not c.flag;
  88.                 end;
  89.           end;
  90.           PassesFilter := Passed;
  91.         end;
  92.    
  93.         Procedure PrintPersonLabel;
  94.         { Prints the Actual label }
  95.    
  96.           Function FormName(L,F,M:string):string;
  97.           { Formats firstname, lastname, middlename fields into an
  98.             acceptable format for a label }
  99.           Var Temp: String;
  100.    
  101.           Begin
  102.             Trim(L);   { Removes trailing blanks from string variable }
  103.             Trim(F);   {  part of ObjectInterFaces general Routines   }
  104.             Trim(M);
  105.             Case F[0] of
  106.               #0 : F := '';                    { Empty }
  107.               #1 : F := Concat(F,'. ');        { Initial - add '. ' }
  108.               Else F := Concat(F,' ');         { Normal  - add space}
  109.             End;
  110.             Case M[0] of
  111.               #0 : M := '';                    { Empty }
  112.               #1 : M := Concat(M,'. ');        { Initial - add '. ' }
  113.               else M := Concat(M,' ');         { Normal  - add space}
  114.             end;
  115.             Temp := concat(F,M,L);
  116.             FormName := Temp;
  117.           end;
  118.    
  119.         begin   {PrintPersonLabel}
  120.           PLine := 1;                     { Global variable in Utiliy Unit }
  121.           while PLine <= topmrgn do
  122.             println(device,0,'');         { ObjectBase - keeps track of print }
  123.    
  124.    
  125.                                         MMGRRPTS.PAS LISTING  PAGE  3    
  126.    
  127.    
  128.                                           { head location print line          }
  129.           PrintLn(device,LftMrgn,
  130.                 FormName(Person.LName,Person.FName,Person.MName));
  131.           if Truncate then
  132.              PrintLn(device,LftMrgn,copy(Company.name,1,rghtmrgn-lftmrgn))
  133.           else
  134.              PrintLn(device,LftMrgn,Company.Name);
  135.           PrintLn(device,LftMrgn,Company.addr1);
  136.           if company.addr2[0] > #0 then
  137.              PrintLn(device,LftMrgn,Company.addr2);
  138.           println(device,LftMrgn,concat(trimmed(company.city),', ',Company.st,
  139.                    '   ', Company.Zip));
  140.           while Pline <= Pagelength do PrintLn(device,0,'');
  141.         end;
  142.    
  143.         Procedure TestPrint;
  144.         { Prints a Sample label until position is accepted by user }
  145.    
  146.         Var Choice : Boolean;
  147.    
  148.         Begin
  149.           Choice := False;
  150.           PushHelp(Ord(TestPrintHelp));
  151.           Repeat
  152.             PLine := 1;
  153.             while PLine <= topmrgn do
  154.               println(device,0,'');
  155.           { Printat() Allows you to format printer data similar to screen }
  156.           { if column location requested is less than the current column  }
  157.           { a linefeed is generated and print head is moved to column     }
  158.           { location requested and data is printed on device. PLine is    }
  159.           { handled as expected.       (ObjectInterFace Routine)          }
  160.             Printat(device,LftMrgn,rpt('*',RghtMrgn-LftMrgn));
  161.             if Truncate then
  162.                Printat(device,LftMrgn,rpt('*',RghtMrgn-LftMrgn))
  163.             else
  164.                Printat(device,LftMrgn,rpt('*',sizeof(Company.name)-1));
  165.             Printat(device,LftMrgn,rpt('*',sizeof(Company.addr1)-1));
  166.             Printat(device,LftMrgn,rpt('*',sizeof(Company.addr1)-1));
  167.             println(device,LftMrgn,concat(rpt('*',sizeof(company.city)-1),
  168.                     ', ',rpt('*',sizeof(Company.st)-1),
  169.                      '   ', rpt('*',sizeof(Company.Zip)-1)));
  170.             while Pline <= Pagelength do PrintLn(device,0,'');
  171.             choice := yesno('Is the Label print in the correct position?');
  172.           Until choice;
  173.           PopHelp;
  174.         end;
  175.    
  176.      var TestValue,
  177.          DvcCode : integer;
  178.          m,mf    : MenuArray;    { Defined in WINDOWS Unit - ObjectInterFace }
  179.          ScrnBuf : Pointer;   { if report sent to screen, must put screen    }
  180.                               { somewhere.                                   }
  181.          w       : WindowRecord; { Defined in WINDOWS Unit - ObjectInterFace }
  182.    
  183.      Begin
  184.    
  185.    
  186.                                         MMGRRPTS.PAS LISTING  PAGE  4    
  187.    
  188.    
  189.        FillChar(M,SizeOf(M),#0);
  190.        WITH M DO
  191.        BEGIN
  192.          Size := 3;
  193.          Txt[ 0] := 'DESTINATION';
  194.          Txt[ 1] := ' Screen';
  195.          Txt[ 2] := ' Printer';
  196.          Txt[ 3] := ' File';
  197.        END;
  198.        FillChar(Mf,SizeOf(Mf),#0);
  199.        WITH Mf DO
  200.        BEGIN
  201.          Size := 3;
  202.          Txt[ 0] := 'SELECTION';
  203.          Txt[ 1] := ' All';
  204.          Txt[ 2] := ' Selected';
  205.          Txt[ 3] := ' Unselected';
  206.        END;
  207.        testValue := 3;
  208.        LabelDefaults.init(10,8,45,14,2,' Label Defaults ',
  209.                       ' <Ctrl Z> Exits Form ');
  210.        with LabelDefaults do       { Objects are similar to Records }
  211.        begin
  212.          Load(new(PckFldPtr,init(21,2,10,m,'Destination:',@DvcCode)));
  213.       { Conditional field - Only appears if DvcCode = TestValue  }
  214.          Load(new(CndFldPtr,init(@DvcCode,intgr,@TestValue,new(strFldPtr,
  215.                   init(21,3,20,'FileName:','Enter File Name',
  216.                   Rpt('!',20),@FileName)))));
  217.          Load(new(PckFldPtr,init(21,5,10,mf,'Selection:',@FilterCode)));
  218.          load(new(intFldPtr,init(30,7,3,0,65,'TopMargin(Lines):',
  219.                   @TopMrgn)));
  220.          load(new(intfldPtr,init(30,8,3,0,65,'PageLength(Lines):',
  221.                   @pagelength)));
  222.          load(new(IntFldPtr,Init(30,9,3,0,132,'LeftMargin(Chars):',
  223.                   @LftMrgn)));
  224.          load(new(IntFldPtr,Init(30,10,3,0,132,'RightMargin(Chars):',
  225.                   @RghtMrgn)));
  226.        end;
  227.        Pushhelp(Ord(ReportFormhelp));
  228.        DvcCode := 2;
  229.        FileName := 'MAILLBLS.TXT';
  230.        TopMrgn := 1;
  231.        RghtMrgn := 35;
  232.        LftMrgn := 2;
  233.        Pagelength := 6;
  234.        FilterCode := 1;
  235.        Labeldefaults.edit;
  236.        labeldefaults.leave;
  237.        Truncate := ((RghtMrgn - LftMrgn) < (Sizeof(Company.Name)-1));
  238.      { LabelDefaults only gets FileName if Device code points to Disk File }
  239.        Case DvcCode of
  240.          1 : FileName := 'CON';
  241.          2 : begin
  242.                FileName := 'PRN';
  243.                if not checkforprinter then
  244.                begin
  245.    
  246.    
  247.                                         MMGRRPTS.PAS LISTING  PAGE  5    
  248.    
  249.    
  250.                  noprintermsg.show;
  251.                  ch := readkey;
  252.                  noprintermsg.hide;
  253.                  goto noprint;
  254.                end;
  255.              end;
  256.        end;
  257.        assign(device,filename);
  258.        rewrite(device);
  259.        if FileName = 'PRN' then
  260.        begin
  261.          SetPrinterMsg.show;
  262.          ch := readKey;
  263.          SetPrinterMsg.hide;
  264.          PrintingMsg.show;
  265.          testprint;
  266.        end
  267.        else if FileName = 'CON' then
  268.          begin
  269.            getmem(ScrnBuf,80*50);
  270.            savewindow(w);
  271.            save_scrn_Rgn(1,1,80,25,ScrnBuf);
  272.            clrscr;
  273.          end;
  274.        with dbase do
  275.        begin
  276.          LoadRelation( PersonData,ContactData,ContactPrsnAccess,
  277.                          @Person.Code);
  278.          LoadRelation( ContactData,CompanyData,CompanySysNdx,
  279.                          @Contact.CompanyCode);
  280.          Switchto(PersonData);
  281.          SetIndex(PersonUserNdx);
  282.          Clear;
  283.          Next;
  284.          Associate(PersonData);
  285.        end;
  286.        While Not dbase.EoFile do
  287.        begin
  288.          If passesfilter(Person,FilterCode) then printPersonlabel;
  289.          dbase.next;
  290.          DBase.Associate(PersonData);
  291.        end;
  292.        If passesfilter(Person,FilterCode) then printPersonlabel;
  293.        if FileName = 'CON' then
  294.        begin
  295.          Gotoxy(1,25);
  296.          Write('Strike a Key to Continue...');
  297.          ch := Readkey;
  298.          Restore_Scrn_Rgn(1,1,80,25,ScrnBuf);
  299.          RestoreWindow(W);
  300.          Freemem(ScrnBuf,80*25*2);
  301.        end;
  302.        Close(Device);
  303.      NoPrint:
  304.        DBase.ClearRelations;
  305.        PrintingMsg.Hide;
  306.    
  307.    
  308.                                         MMGRRPTS.PAS LISTING  PAGE  6    
  309.    
  310.    
  311.        LabelDeFaults.done;
  312.        PopHelp;
  313.      End;
  314.    
  315.      Procedure CompanyLabel;
  316.    
  317.      label noprint;
  318.    
  319.      var OldDataFile,
  320.          OldNdxFile,
  321.          FileName: FName;
  322.          LabelDefaults : Form;
  323.          LftMrgn,
  324.          RghtMrgn,
  325.          TopMrgn,
  326.          FilterCode,
  327.          PageLength : integer;
  328.          Device: text;
  329.          Tfile: oopfile;
  330.          truncate : Boolean;
  331.          ch : char;
  332.    
  333.         function PassesFilter(c : CompanyType; code: integer): Boolean;
  334.         var passed : Boolean;
  335.    
  336.         begin
  337.           Passed := true;
  338.           Case Code of
  339.             2 : begin    { flagged records only }
  340.                   passed := c.flag;
  341.                 end;
  342.             3 : begin    { unflagged records only }
  343.                   passed := not c.flag;
  344.                 end;
  345.           end;
  346.           PassesFilter := Passed;
  347.         end;
  348.    
  349.         procedure printCompanyLabel;
  350.         begin
  351.           PLine := 1;
  352.           while PLine <= topmrgn do
  353.             println(device,0,'');
  354.           if Truncate then
  355.              PrintLn(device,LftMrgn,copy(Company.name,1,rghtmrgn-lftmrgn))
  356.           else
  357.              PrintLn(device,LftMrgn,Company.Name);
  358.           PrintLn(device,LftMrgn,Company.addr1);
  359.           if company.addr2[0] > #0 then
  360.              PrintLn(device,LftMrgn,Company.addr2);
  361.           println(device,LftMrgn,concat(trimmed(company.city),', ',Company.st,
  362.                    '   ', Company.Zip));
  363.           while Pline <= Pagelength do PrintLn(device,0,'');
  364.         end;
  365.    
  366.         procedure testprint;
  367.    
  368.    
  369.                                         MMGRRPTS.PAS LISTING  PAGE  7    
  370.    
  371.    
  372.    
  373.         var choice : boolean;
  374.    
  375.         begin
  376.           Choice := False;
  377.           PushHelp(ord(TestPrintHelp));
  378.           Repeat
  379.             PLine := 1;
  380.             while PLine <= topmrgn do
  381.               println(device,0,'');
  382.             if Truncate then
  383.                Printat(device,LftMrgn,rpt('*',RghtMrgn-LftMrgn))
  384.             else
  385.                Printat(device,LftMrgn,rpt('*',sizeof(Company.name)-1));
  386.             Printat(device,LftMrgn,rpt('*',sizeof(Company.addr1)-1));
  387.             Printat(device,LftMrgn,rpt('*',sizeof(Company.addr1)-1));
  388.             println(device,LftMrgn,concat(rpt('*',sizeof(company.city)-1),
  389.                     ', ',rpt('*',sizeof(Company.st)-1),
  390.                      '   ', rpt('*',sizeof(Company.Zip)-1)));
  391.             while Pline <= Pagelength do PrintLn(device,0,'');
  392.             choice := yesno('Is the Label print in the correct position?');
  393.           Until choice;
  394.           PopHelp;
  395.         end;
  396.    
  397.      var TestValue,
  398.          DvcCode : integer;
  399.          m,mf    : MenuArray;
  400.          ScrnBuf : Pointer;
  401.          w       : WindowRecord;
  402.    
  403.      Begin
  404.        FillChar(M,SizeOf(M),#0);
  405.        WITH M DO
  406.        BEGIN
  407.          Size := 3;
  408.          Txt[ 0] := 'DESTINATION';
  409.          Txt[ 1] := ' Screen';
  410.          Txt[ 2] := ' Printer';
  411.          Txt[ 3] := ' File';
  412.        END;
  413.        FillChar(Mf,SizeOf(Mf),#0);
  414.        WITH Mf DO
  415.        BEGIN
  416.          Size := 3;
  417.          Txt[ 0] := 'SELECTION';
  418.          Txt[ 1] := ' All';
  419.          Txt[ 2] := ' Flagged';
  420.          Txt[ 3] := ' Unflagged';
  421.        END;
  422.        testValue := 3;
  423.        LabelDefaults.init(10,8,45,14,2,' Label Defaults ','');
  424.        with LabelDefaults do
  425.        begin
  426.          Load(new(PckFldPtr,init(21,2,10,m,'Destination:',@DvcCode)));
  427.          Load(new(CndFldPtr,init(@DvcCode,intgr,@TestValue,new(strFldPtr,
  428.    
  429.    
  430.                                         MMGRRPTS.PAS LISTING  PAGE  8    
  431.    
  432.    
  433.                   init(21,3,20,'FileName:','Enter File Name',
  434.                   Rpt('!',20),@FileName)))));
  435.          Load(new(PckFldPtr,init(21,5,10,mf,'Selection:',@FilterCode)));
  436.          load(new(intFldPtr,init(30,7,3,0,65,'TopMargin(Lines):',
  437.                   @TopMrgn)));
  438.          load(new(intfldPtr,init(30,8,3,0,65,'PageLength(Lines):',
  439.                   @pagelength)));
  440.          load(new(IntFldPtr,Init(30,9,3,0,132,'LeftMargin(Chars):',
  441.                   @LftMrgn)));
  442.          load(new(IntFldPtr,Init(30,10,3,0,132,'RightMargin(Chars):',
  443.                   @RghtMrgn)));
  444.        end;
  445.        Truncate := ((RghtMrgn - LftMrgn) < (Sizeof(Company.Name)-1));
  446.        DvcCode := 2;
  447.        FileName := 'MAILLBLS.TXT';
  448.        TopMrgn := 1;
  449.        RghtMrgn := 35;
  450.        LftMrgn := 2;
  451.        Pagelength := 6;
  452.        FilterCode := 1;
  453.        PushHelp(Ord(ReportFormHelp));
  454.        Labeldefaults.edit;
  455.        labeldefaults.leave;
  456.        Case DvcCode of
  457.          1 : FileName := 'CON';
  458.          2 : begin
  459.                FileName := 'PRN';
  460.                if not checkforprinter then
  461.                begin
  462.                  noprintermsg.show;
  463.                  ch := readkey;
  464.                  noprintermsg.hide;
  465.                  goto noprint;
  466.                end;
  467.              end;
  468.        end;
  469.        assign(device,filename);
  470.        rewrite(device);
  471.        if FileName = 'PRN' then
  472.        begin
  473.          SetPrinterMsg.show;
  474.          ch := readKey;
  475.          SetPrinterMsg.hide;
  476.          PrintingMsg.show;
  477.          testprint;
  478.        end
  479.        else if FileName = 'CON' then
  480.          begin
  481.            getmem(ScrnBuf,80*50);
  482.            savewindow(w);
  483.            save_scrn_Rgn(1,1,80,25,ScrnBuf);
  484.            clrscr;
  485.          end;
  486.        with dbase do
  487.        begin
  488.          SwitchTo(CompanyData);
  489.    
  490.    
  491.                                         MMGRRPTS.PAS LISTING  PAGE  9    
  492.    
  493.    
  494.          SetIndex(CompanyUserNdx);
  495.          Clear;
  496.          Next;
  497.        end;
  498.        While Not dbase.EoFile do
  499.        begin
  500.          If passesfilter(Company,FilterCode) then printcompanylabel;
  501.          dbase.next;
  502.        end;
  503.        If passesfilter(Company,FilterCode) then printcompanylabel;
  504.        if FileName = 'CON' then
  505.        begin
  506.          Gotoxy(1,25);
  507.          Write('Strike a Key to Continue...');
  508.          ch := Readkey;
  509.          Restore_Scrn_Rgn(1,1,80,25,ScrnBuf);
  510.          RestoreWindow(W);
  511.          Freemem(ScrnBuf,80*25*2);
  512.        end;
  513.        PrintingMsg.Hide;
  514.        Close(Device);
  515.      NoPrint:
  516.        LabelDeFaults.done;
  517.        PopHelp;
  518.      End;
  519.    
  520.    var
  521.        choice : integer;
  522.        Finished : Boolean;
  523.    begin
  524.      pushhelp(ord(labelhelp));
  525.      Finished := False;
  526.      Repeat
  527.        Choice := labelsMenu.Pop;
  528.        LabelsMenu.Leave;
  529.        CASE Choice of
  530.          1 : contlabel;
  531.          2 : Companylabel;
  532.          3 : Finished := True;
  533.        End;
  534.      Until Finished;
  535.      LabelsMenu.Hide;
  536.      pophelp;
  537.    end;
  538.    
  539.    Procedure comp_W_Contacts;
  540.    label NoPrint;
  541.    var
  542.        choice : integer;
  543.        ch : char;
  544.        Another_Contact : Boolean;
  545.        Title,
  546.        Device,
  547.        OldCode : string;
  548.        delimstrt,
  549.        delimfnsh  : string[2];
  550.    
  551.    
  552.                                         MMGRRPTS.PAS LISTING  PAGE  10   
  553.    
  554.    
  555.        Dest   : Text;
  556.        scrn   : array[1..2000] of word;
  557.        w      : windowrecord;
  558.        i,
  559.        colpos,
  560.        tfiletype,
  561.        PageNo,
  562.        PageLength : integer;
  563.        m : menuarray;
  564.        fn     : form;
  565.    
  566.      Procedure DispCwCntBlock;
  567.    
  568.        Procedure DispContact;
  569.        begin
  570.          PrintAt(Dest,LeftMargin+31,
  571.                  concat(trimmed(person.LName),', ',trimmed(person.FName),' ',
  572.                  trimmed(person.MName)));
  573.          Printat(Dest,RightMargin-sizeof(Contact.Position),
  574.                       concat(delimstrt,Trimmed(Contact.Position),delimfnsh));
  575.        end;
  576.    
  577.      begin
  578.          another_contact := True;
  579.        { print next PLine }
  580.          IF (PLine >= PageLength - BottomMargin) and (PageLength > -1) then
  581.          begin
  582.          { Print Header }
  583.            if PageNo > 0 then formfeed(Dest,Device);
  584.            PLine := 0;
  585.            While PLine < TopMargin do
  586.              PrintLn(Dest,0,'');
  587.            Inc(PageNo);
  588.            PrintAt(Dest,LeftMargin,DateStr(Today,mmddyyyy));
  589.            PrintAt(Dest,((RightMargin-Length(title)) div 2), Title);
  590.            PrintLn(dest,RightMargin-8,concat('Page ',i_str(PageNo,3)));
  591.            PrintLn(Dest,0,'');
  592.            PrintAt(dest,LeftMargin,'COMPANY');
  593.            PrintLn(Dest,LeftMargin+31,
  594.            'CONTACT');
  595.            PrintLn(dest,LeftMargin, rpt('-',RightMargin-LeftMargin));
  596.          end;
  597.        { Print company name }
  598.          Printat(Dest,LeftMargin,copy(Company.Name,1,28));
  599.        { Print contact name and position }
  600.          DispContact;
  601.          DBase.NextAssoc(CompanyData);
  602.          if OldCode = Person.Code then another_Contact := False;
  603.        { NewLine }
  604.          println(dest,0,'');
  605.        { Print Company address 1 }
  606.          Printat(Dest,LeftMargin,Company.Addr1);
  607.          If another_contact then
  608.          begin
  609.            DispContact;
  610.            DBase.NextAssoc(CompanyData);
  611.    
  612.    
  613.                                         MMGRRPTS.PAS LISTING  PAGE  11   
  614.    
  615.    
  616.            if OldCode = Person.Code then another_Contact := False;
  617.          end;
  618.        { NewLine }
  619.          println(dest,0,'');
  620.          If Company.addr2 <> '' then
  621.          begin
  622.            Printat(Dest,LeftMargin,Company.Addr2);
  623.            If another_contact then
  624.            begin
  625.              DispContact;
  626.              DBase.NextAssoc(CompanyData);
  627.              if OldCode = Person.Code then another_Contact := False;
  628.            end;
  629.          { NewLine }
  630.            println(dest,0,'');
  631.          end;
  632.        { print company city st zip }
  633.          Printat(Dest,LeftMargin,
  634.                  concat(Company.City,', ',Company.St,'  ',
  635.                         Formatted(ZipMask,Company.zip)));
  636.          If another_contact then
  637.          begin
  638.            DispContact;
  639.            DBase.NextAssoc(CompanyData);
  640.            if OldCode = Person.Code then another_Contact := False;
  641.          end;
  642.          println(Dest,0,'');
  643.        { Print company Phone }
  644.          PrintAt(Dest,LeftMargin,
  645.                  formatted(phnMask,company.phone));
  646.          While another_contact do
  647.          begin
  648.            DispContact;
  649.            DBase.NextAssoc(CompanyData);
  650.            if OldCode = Person.Code then another_Contact := False;
  651.          end;
  652.    
  653.        { NewLine }
  654.          println(dest,0,'');
  655.          println(dest,0,'');
  656.      end;
  657.    
  658.      Procedure PrintCwCntBlock;
  659.    
  660.        procedure PrintContact;
  661.        begin
  662.          If another_contact then
  663.          begin
  664.            PrintAt(Dest,LeftMargin+SizeOf(Company.Name)+Length(PhnMask)+1,
  665.                    concat(person.LName,', ',person.FName,' ',person.MName));
  666.            Printat(Dest,RightMargin-sizeof(Contact.Position),
  667.                         concat(delimstrt,Trimmed(Contact.Position),delimfnsh));
  668.            DBase.NextAssoc(CompanyData);
  669.            if OldCode = Person.Code then another_Contact := False;
  670.          end;
  671.        end;
  672.    
  673.    
  674.                                         MMGRRPTS.PAS LISTING  PAGE  12   
  675.    
  676.    
  677.    
  678.      begin
  679.          another_contact := True;
  680.        { print next PLine }
  681.          IF (PLine >= PageLength - BottomMargin) and (PageLength > -1) then
  682.          begin
  683.          { Print Header }
  684.            if PageNo > 0 then formfeed(Dest,Device);
  685.            PLine := 0;
  686.            While PLine < TopMargin do
  687.              PrintLn(Dest,0,'');
  688.            Inc(PageNo);
  689.            PrintAt(Dest,LeftMargin,DateStr(Today,mmddyyyy));
  690.            PrintAt(Dest,((RightMargin-Length(title)) div 2), Title);
  691.            PrintLn(dest,RightMargin-8,concat('Page ',i_str(PageNo,3)));
  692.            PrintLn(Dest,0,'');
  693.            PrintAt(dest,LeftMargin,'COMPANY');
  694.            PrintAt(Dest,LeftMargin+SizeOf(Company.Name),'PHONE');
  695.            PrintAt(Dest,LeftMargin+SizeOf(Company.Name)+Length(PhnMask)+1,
  696.            'CONTACT');
  697.            PrintLn(Dest,RightMargin-sizeof(Contact.Position),'POSITION');
  698.            PrintLn(dest,LeftMargin, rpt('-',RightMargin-LeftMargin));
  699.          end;
  700.        { Print company name }
  701.          Printat(Dest,LeftMargin,Company.Name);
  702.        { Print company Phone }
  703.          PrintAt(Dest,LeftMargin+SizeOf(Company.Name),
  704.                  formatted(phnMask,company.phone));
  705.        { Print contact name and position }
  706.          PrintContact;
  707.        { NewLine }
  708.          println(dest,0,'');
  709.        { Print Company address 1 }
  710.          Printat(Dest,LeftMargin,Company.Addr1);
  711.          PrintContact;
  712.        { NewLine }
  713.          println(dest,0,'');
  714.          If Company.addr2 <> '' then
  715.          begin
  716.            Printat(Dest,LeftMargin,Company.Addr2);
  717.            printcontact;
  718.          { NewLine }
  719.            println(dest,0,'');
  720.          end;
  721.        { print company city st zip }
  722.          Printat(Dest,LeftMargin,
  723.                  concat(Company.City,', ',Company.St,'  ',
  724.                         Formatted(ZipMask,Company.zip)));
  725.          while another_contact do PrintContact;
  726.        { NewLine }
  727.          println(dest,0,'');
  728.          println(dest,0,'');
  729.      end;
  730.    
  731.    begin
  732.      another_Contact := true;
  733.    
  734.    
  735.                                         MMGRRPTS.PAS LISTING  PAGE  13   
  736.    
  737.    
  738.      pushhelp(ord(reporthelp));
  739.      Choice := DeviceMenu.Pop;
  740.      delimstrt := '';
  741.      delimfnsh := '';
  742.      tfiletype := 0;
  743.      DeviceMenu.Hide;
  744.      CASE Choice of
  745.        1 : begin
  746.              Device      := 'CON';
  747.              LeftMargin  :=  0;
  748.              rightmargin := 79;
  749.              topmargin   :=  0;
  750.              Bottommargin:=  4;
  751.              pagelength  := 24;
  752.              savewindow(w);
  753.              save_Scrn_Rgn(1,1,80,25,@scrn);
  754.              clrscr;
  755.            end;
  756.        2 : begin
  757.              Device      := 'PRN';
  758.              if not checkforprinter then
  759.              begin
  760.                 noprintermsg.show;
  761.                 ch := readkey;
  762.                 noprintermsg.hide;
  763.                 goto noprint;
  764.              end;
  765.              LeftMargin  :=  5;
  766.              RightMargin := 120;
  767.              topmargin   :=  2;
  768.              Bottommargin:=  7;
  769.              PageLength  := 66;
  770.              SetPrinterMsg.show;
  771.              ch := readKey;
  772.              SetPrinterMsg.hide;
  773.              PrintingMsg.show;
  774.            end;
  775.        3 : begin
  776.              Device      := 'REPORT.PRN';
  777.              fn.init(20,8,40,6,QueryBorder,' FILE NAME ','');
  778.              fn.Load(new(strfldptr,init(13,2,25,'Path + Name:',
  779.              'Enter Path & Name of File',rpt('!',25),@Device)));
  780.              fn.edit;
  781.              fn.hide;
  782.              fn.done;
  783.              delimstrt := '';
  784.              delimfnsh := '';
  785.              LeftMargin  :=  5;
  786.              RightMargin := 125;
  787.              topmargin   :=  2;
  788.              Bottommargin:=  7;
  789.              PageLength  := 66;
  790.              ff          := concat(#12);
  791.              PrintingMsg.show;
  792.            end;
  793.        4 : begin
  794.    
  795.    
  796.                                         MMGRRPTS.PAS LISTING  PAGE  14   
  797.    
  798.    
  799.             PopHelp;
  800.             exit;
  801.            end;
  802.      End;
  803.      assign(Dest,device);
  804.      rewrite(dest);
  805.      PLine := PageLength + 1;
  806.      if device = 'PRN' then write(Dest,#15);
  807.      PCol := 0;
  808.      DBase.LoadRelation( CompanyData,ContactData,ContactCompAccess,
  809.                          @Company.Code);
  810.      DBase.loadRelation( ContactData,PersonData,PersonSysNdx,
  811.                          @Contact.personCode);
  812.      DBase.Switchto(CompanyData);
  813.      DBase.SetIndex(CompanyUserNdx);
  814.      dbase.top;
  815.      DBase.Associate(CompanyData);
  816.      OldCode := Person.Code;
  817.      Title := '**** C O M P A N Y   L I S T I N G ****';
  818.      PageNo := 0;
  819.      while Not DBase.EoFile DO
  820.      begin
  821.        if Device = 'CON' then
  822.          DispCwCntBlock
  823.        else
  824.          PrintCwCntBlock;
  825.        DBase.Next;
  826.        DBase.Associate(CompanyData);
  827.        OldCode := Person.Code;
  828.      end;
  829.      if Device = 'CON' then
  830.        DispCwCntBlock
  831.      else
  832.        PrintCwCntBlock;
  833.    { NewLine }
  834.      println(dest,0,'');
  835.      formfeed(dest,Device);
  836.      if Device = 'CON'then
  837.      begin
  838.        restore_Scrn_Rgn(1,1,80,25,@scrn);
  839.        RestoreWindow(w);
  840.      end
  841.      else
  842.        printingmsg.hide;
  843.      close(dest);
  844.      DBase.ClearRelations;
  845.    Noprint:
  846.      pophelp;
  847.    end;
  848.    
  849.    
  850.    Procedure Comp_WO_Contacts;
  851.    var
  852.        FileName: FName;
  853.        LabelDefaults : Form;
  854.        LftMrgn,
  855.    
  856.    
  857.                                         MMGRRPTS.PAS LISTING  PAGE  15   
  858.    
  859.    
  860.        RghtMrgn,
  861.        BtmMrgn,
  862.        TopMrgn,
  863.        PageNo,
  864.        FilterCode,
  865.        PageLength : integer;
  866.        Title : String;
  867.        Device: text;
  868.        ToPrint: Boolean;
  869.    
  870.       function PassesFilter(c : CompanyType; code: integer): Boolean;
  871.       var passed : Boolean;
  872.    
  873.       begin
  874.         Passed := true;
  875.         Case Code of
  876.           2 : begin    { flagged records only }
  877.                 passed := c.flag;
  878.               end;
  879.           3 : begin    { unflagged records only }
  880.                 passed := not c.flag;
  881.               end;
  882.         end;
  883.         PassesFilter := Passed;
  884.       end;
  885.    
  886.       procedure NewPage;
  887.       VAR CH: CHAR;
  888.       begin
  889.          if ToPrint then
  890.          begin
  891.            if PageNo > 0 then formfeed(Device,FileName);
  892.            PLine := 0;
  893.            While PLine < TopMrgn do
  894.              PrintLn(Device,0,'');
  895.            Inc(PageNo);
  896.            PrintAt(Device,LftMrgn,DateStr(Today,mmddyyyy));
  897.            PrintAt(Device,((RghtMrgn-Length(title)) div 2), Title);
  898.            PrintLn(Device,RghtMrgn-8,concat('Page ',i_str(PageNo,3)));
  899.            PrintLn(Device,0,'');
  900.            PrintAt(Device,LftMrgn,'COMPANY NAME');
  901.            PrintAt(Device,LftMrgn+SizeOf(Company.Name),'ADDRESS');
  902.            PrintAt(Device,LftMrgn+SizeOf(Company.Name) + SizeOf(Company.Addr1),
  903.                    'CITY / ST / ZIP');
  904.            PrintLn(Device,LftMrgn,'PHONE');
  905.            PrintLn(Device,LftMrgn, rpt('-',RghtMrgn-LftMrgn));
  906.          end
  907.          else
  908.          begin
  909.            If PageNo > 0 then
  910.            begin
  911.              GotoXY(1,25);
  912.              Write('Press any Key to Continue...');
  913.              ch := ReadKey;
  914.              clrscr;
  915.            end;
  916.    
  917.    
  918.                                         MMGRRPTS.PAS LISTING  PAGE  16   
  919.    
  920.    
  921.            PLine := 0;
  922.            Inc(PageNo);
  923.            PrintAt(Device,LftMrgn,DateStr(Today,mmddyyyy));
  924.            PrintAt(Device,((RghtMrgn-Length(title)) div 2), Title);
  925.            PrintLn(Device,RghtMrgn-8,concat('Page ',i_str(PageNo,3)));
  926.            PrintLn(Device,0,'');
  927.            PrintAt(Device,LftMrgn,'COMPANY NAME');
  928.            Println(Device,LftMrgn+SizeOf(Company.Name),'CITY');
  929.            PrintAt(Device,LftMrgn,'ADDRESS');
  930.            Println(Device,LftMrgn+SizeOf(Company.Name),'STATE / ZIP');
  931.            PrintLn(Device,LftMrgn+SizeOf(Company.Name),'PHONE');
  932.            PrintLn(Device,LftMrgn, rpt('-',RghtMrgn-LftMrgn));
  933.          end;
  934.       end;
  935.    
  936.       procedure PrintCompanyLine;
  937.       begin
  938.         if toPrint then
  939.         begin
  940.           if PLine > PageLength - BtmMrgn then newpage;
  941.           Printat(device,LftMrgn,Company.name);
  942.           Printat(device,LftMrgn+sizeof(company.name),Company.addr1);
  943.           Printat(device,LftMrgn+Sizeof(Company.name)+sizeof(company.addr1),
  944.                   concat(trimmed(company.city),', ',
  945.                   company.st,'  ',trimmed(company.zip)));
  946.           printat(device,LftMrgn,formatted('(999)999-99999',company.phone));
  947.           Printat(device,LftMrgn+sizeof(company.name),Company.addr2);
  948.         end
  949.         else
  950.         begin
  951.           if PLine > PageLength - BtmMrgn then newpage;
  952.           Printat(device,LftMrgn,Company.name);
  953.           PrintLn(device,LftMrgn+sizeof(company.name),Company.City);
  954.           Printat(device,LftMrgn,Company.addr1);
  955.           PrintLn(device,LftMrgn+sizeof(company.name),concat(Company.St,
  956.                          ' ',Company.zip));
  957.           Printat(device,LftMrgn,Company.Addr2);
  958.           printLn(device,LftMrgn+sizeof(company.name),
  959.                   formatted('(999)999-99999',company.phone));
  960.           PrintLn(Device,0,'');
  961.         end;
  962.       end;
  963.    
  964.    label noprint;
  965.    
  966.    var TestValue,
  967.        DvcCode : integer;
  968.        m,mf    : MenuArray;
  969.        ch      : Char;
  970.        ScrnBuf : Pointer;
  971.        w       : WindowRecord;
  972.    
  973.    Begin
  974.      FillChar(M,SizeOf(M),#0);
  975.      WITH M DO
  976.      BEGIN
  977.    
  978.    
  979.                                         MMGRRPTS.PAS LISTING  PAGE  17   
  980.    
  981.    
  982.        Size := 3;
  983.        Txt[ 0] := 'DESTINATION';
  984.        Txt[ 1] := ' Screen';
  985.        Txt[ 2] := ' Printer';
  986.        Txt[ 3] := ' File';
  987.      END;
  988.      FillChar(Mf,SizeOf(Mf),#0);
  989.      WITH Mf DO
  990.      BEGIN
  991.        Size := 3;
  992.        Txt[ 0] := 'SELECTION';
  993.        Txt[ 1] := ' All';
  994.        Txt[ 2] := ' Flagged';
  995.        Txt[ 3] := ' Unflagged';
  996.      END;
  997.      testValue := 3;
  998.      LabelDefaults.init(10,8,45,14,2,' Label Defaults ','');
  999.      with LabelDefaults do
  1000.      begin
  1001.        Load(new(PckFldPtr,init(21,2,10,m,'Destination:',@DvcCode)));
  1002.        Load(new(CndFldPtr,init(@DvcCode,intgr,@TestValue,new(strFldPtr,
  1003.                 init(21,3,20,'FileName:','Enter File Name',
  1004.                 Rpt('!',20),@FileName)))));
  1005.        Load(new(PckFldPtr,init(21,5,10,mf,'Selection:',@FilterCode)));
  1006.        load(new(intFldPtr,init(30,7,3,0,5,'TopMargin(Lines):',
  1007.                 @TopMrgn)));
  1008.        load(new(intfldPtr,init(30,8,3,0,66,'PageLength(Lines):',
  1009.                 @pagelength)));
  1010.        load(new(IntFldPtr,Init(30,9,3,0,132,'Line Width(Chars):',
  1011.                 @RghtMrgn)));
  1012.      end;
  1013.      PushHelp(Ord(ReportFormHelp));
  1014.      DvcCode := 2;
  1015.      FileName := 'COMPRPT.TXT';
  1016.      BtmMrgn := 3;
  1017.      PageNo := 0;
  1018.      TopMrgn := 1;
  1019.      RghtMrgn := 80;
  1020.      LftMrgn := 5;
  1021.      Pagelength := 66;
  1022.      FilterCode := 1;
  1023.      Title := '*** C O M P A N Y   L I S T ***';
  1024.      ToPrint := True;
  1025.      Labeldefaults.edit;
  1026.      labeldefaults.leave;
  1027.      Case DvcCode of
  1028.        1 : begin
  1029.              FileName := 'CON';
  1030.            end;
  1031.        2 : Begin
  1032.              FileName := 'PRN';
  1033.              if not checkforprinter then
  1034.              begin
  1035.                noprintermsg.show;
  1036.                ch := readkey;
  1037.                noprintermsg.hide;
  1038.    
  1039.    
  1040.                                         MMGRRPTS.PAS LISTING  PAGE  18   
  1041.    
  1042.    
  1043.                goto noprint;
  1044.              end;
  1045.            end;
  1046.      end;
  1047.      assign(device,filename);
  1048.      rewrite(device);
  1049.      if FileName = 'PRN' then
  1050.      begin
  1051.        SetPrinterMsg.show;
  1052.        ch := readKey;
  1053.        SetPrinterMsg.hide;
  1054.        PrintingMsg.show;
  1055.        if rghtmrgn < 120 then
  1056.        BEGIN
  1057.          RGHTMRGN := LftMrgn + SizeOf(Company.Name) +
  1058.                      SizeOf(Company.addr1) + SizeOf(Company.St) +
  1059.                      SizeOf(Company.City) + SizeOf(Company.Zip) + 4;
  1060.          write(device,#15);
  1061.        END;
  1062.      end
  1063.      else if FileName = 'CON' then
  1064.        begin
  1065.          getmem(ScrnBuf,80*50);
  1066.          savewindow(w);
  1067.          save_scrn_Rgn(1,1,80,25,ScrnBuf);
  1068.          clrscr;
  1069.          LftMrgn := 0;
  1070.          RghtMrgn := 79;
  1071.          PageLength := 24;
  1072.          BtmMrgn := 2;
  1073.          ToPrint := False;
  1074.        end;
  1075.      with dbase do
  1076.      begin
  1077.        SwitchTo(CompanyData);
  1078.        SetIndex(CompanyUserNdx);
  1079.        Clear;
  1080.        Next;
  1081.      end;
  1082.      Pline := PageLength +1;
  1083.      While Not dbase.EoFile do
  1084.      begin
  1085.        If passesfilter(Company,FilterCode) then PrintCompanyLine;
  1086.        dbase.next;
  1087.      end;
  1088.      If passesfilter(Company,FilterCode) then PrintCompanyLine;
  1089.      if FileName = 'CON' then
  1090.      begin
  1091.        Gotoxy(1,25);
  1092.        Write('Strike a Key to Continue...');
  1093.        ch := Readkey;
  1094.        Restore_Scrn_Rgn(1,1,80,25,ScrnBuf);
  1095.        RestoreWindow(W);
  1096.        Freemem(ScrnBuf,80*25*2);
  1097.      end
  1098.      else formfeed(device,filename);
  1099.    
  1100.    
  1101.                                         MMGRRPTS.PAS LISTING  PAGE  19   
  1102.    
  1103.    
  1104.      PrintingMsg.Hide;
  1105.      close(Device);
  1106.    NoPrint:
  1107.      LabelDeFaults.done;
  1108.      PopHelp;
  1109.    end;
  1110.    
  1111.    
  1112.    Procedure CompanyReports;
  1113.    
  1114.    var ch : char;
  1115.        choice : integer;
  1116.        Finished : Boolean;
  1117.    begin
  1118.      pushhelp(ord(reporthelp));
  1119.      Finished := False;
  1120.      Repeat
  1121.        Choice := CompLstMenu.Pop;
  1122.        CompLstMenu.Leave;
  1123.        CASE Choice of
  1124.          1 : begin
  1125.                comp_W_Contacts;
  1126.              end;
  1127.          2 : begin
  1128.                comp_WO_Contacts
  1129.              end;
  1130.          3 : Finished := True;
  1131.        End;
  1132.      Until Finished;
  1133.      CompLstMenu.Hide;
  1134.      pophelp;
  1135.    end;
  1136.    
  1137.    Procedure ContactReports;
  1138.    Label NoPrint;
  1139.    var
  1140.        choice : integer;
  1141.        ch : char;
  1142.        NewPerson : Boolean;
  1143.        Title,
  1144.        Device,
  1145.        OldCode : string;
  1146.        delimstrt,
  1147.        delimfnsh  : string[2];
  1148.        Dest   : Text;
  1149.        scrn   : array[1..2000] of word;
  1150.        w      : windowrecord;
  1151.        i,
  1152.        colpos,
  1153.        tfiletype,
  1154.        PageNo,
  1155.        PageLength : integer;
  1156.        m : menuarray;
  1157.        fn     : form;
  1158.    
  1159.    begin
  1160.    
  1161.    
  1162.                                         MMGRRPTS.PAS LISTING  PAGE  20   
  1163.    
  1164.    
  1165.      pushhelp(ord(reporthelp));
  1166.      Choice := DeviceMenu.Pop;
  1167.      delimstrt := '';
  1168.      delimfnsh := '';
  1169.      tfiletype := 0;
  1170.      DeviceMenu.Hide;
  1171.      CASE Choice of
  1172.        1 : begin
  1173.              Device      := 'CON';
  1174.              LeftMargin  :=  0;
  1175.              rightmargin := 79;
  1176.              topmargin   :=  0;
  1177.              Bottommargin:=  0;
  1178.              pagelength  := 24;
  1179.              savewindow(w);
  1180.              save_Scrn_Rgn(1,1,80,25,@scrn);
  1181.              clrscr;
  1182.            end;
  1183.        2 : begin
  1184.              Device      := 'PRN';
  1185.              if not checkforprinter then
  1186.              begin
  1187.                 noprintermsg.show;
  1188.                 ch := readkey;
  1189.                 noprintermsg.hide;
  1190.                 goto noprint;
  1191.              end;
  1192.              LeftMargin  :=  1;
  1193.              RightMargin := 79;
  1194.              topmargin   :=  2;
  1195.              Bottommargin:=  2;
  1196.              PageLength  := 66;
  1197.              SetPrinterMsg.show;
  1198.              ch := readKey;
  1199.              SetPrinterMsg.hide;
  1200.              PrintingMsg.show;
  1201.            end;
  1202.        3 : begin
  1203.              Device      := 'REPORT.PRN';
  1204.              fn.init(20,8,40,7,QueryBorder,' FILE NAME ','');
  1205.              fn.load(new(StrFldPtr,init(11,2,25,'FileName:',
  1206.               'Enter path & file to save report to ...',rpt('!',25),@Device)));
  1207.              WITH M DO
  1208.              BEGIN
  1209.                Size := 4;
  1210.                Txt[ 0] := 'SELECT';
  1211.                Txt[ 1] := ' 1 Print File';
  1212.                Txt[ 2] := ' 2 Comma Delimited';
  1213.                Txt[ 3] := ' 3 Quote Delimited';
  1214.                Txt[ 4] := ' 4 Quote+Comma';
  1215.              END;
  1216.              fn.load(new(PckFldPtr,init(11,3,15,m,'Format:',@tfiletype)));
  1217.              fn.edit;
  1218.              fn.hide;
  1219.              fn.done;
  1220.              Case tfileType of
  1221.    
  1222.    
  1223.                                         MMGRRPTS.PAS LISTING  PAGE  21   
  1224.    
  1225.    
  1226.                1 : begin
  1227.                      delimstrt := '';
  1228.                      delimfnsh := '';
  1229.                      LeftMargin  :=  1;
  1230.                      RightMargin := 79;
  1231.                      topmargin   :=  2;
  1232.                      Bottommargin:=  2;
  1233.                      PageLength  := 66;
  1234.                      ff          := concat(#12);
  1235.                    end;
  1236.                2 : begin
  1237.                      delimstrt := '';
  1238.                      delimfnsh := ',';
  1239.                      LeftMargin  :=  0;
  1240.                      RightMargin :=  0;
  1241.                      topmargin   :=  0;
  1242.                      Bottommargin:= -1;
  1243.                      PageLength  := -1;
  1244.                      ff          := '';
  1245.                    end;
  1246.                3 : begin
  1247.                      delimstrt := '"';
  1248.                      delimfnsh := '"';
  1249.                      LeftMargin  :=  0;
  1250.                      RightMargin :=  0;
  1251.                      topmargin   :=  0;
  1252.                      Bottommargin:= -1;
  1253.                      PageLength  := -1;
  1254.                      ff          := '';
  1255.                    end;
  1256.                4 : begin
  1257.                      delimstrt := '"';
  1258.                      delimfnsh := '",';
  1259.                      LeftMargin  :=  0;
  1260.                      RightMargin :=  0;
  1261.                      topmargin   :=  0;
  1262.                      Bottommargin:= -1;
  1263.                      PageLength  := -1;
  1264.                      ff          := '';
  1265.                    end;
  1266.              end;
  1267.              PrintingMsg.show;
  1268.            end;
  1269.        4 : begin
  1270.             PopHelp;
  1271.             exit;
  1272.            end;
  1273.      End;
  1274.      assign(Dest,device);
  1275.      rewrite(dest);
  1276.      PLine := PageLength + 1;
  1277.      PCol := 0;
  1278.      DBase.LoadRelation( PersonData,ContactData,ContactPrsnAccess,
  1279.                          @Person.Code);
  1280.      DBase.loadRelation( ContactData,CompanyData,CompanySysNdx,
  1281.                          @Contact.CompanyCode);
  1282.    
  1283.    
  1284.                                         MMGRRPTS.PAS LISTING  PAGE  22   
  1285.    
  1286.    
  1287.      DBase.Switchto(PersonData);
  1288.      DBase.SetIndex(PersonUserNdx);
  1289.      dbase.top;
  1290.      DBase.Associate(PersonData);
  1291.      OldCode := Company.Code;
  1292.      Title := '**** C O N T A C T   L I S T ****';
  1293.      PageNo := 0;
  1294.      NewPerson := True;
  1295.      while NOT DBase.EoFile DO
  1296.      begin
  1297.      { print next PLine }
  1298.        IF (PLine >= PageLength - BottomMargin) and (PageLength > -1) then
  1299.        begin
  1300.        { Print Header }
  1301.          if PageNo > 0 then formfeed(Dest,Device);
  1302.          PLine := 0;
  1303.          While PLine < TopMargin do
  1304.            PrintLn(Dest,0,'');
  1305.          Inc(PageNo);
  1306.          PrintAt(Dest,LeftMargin,DateStr(Today,mmddyyyy));
  1307.          PrintAt(Dest,((RightMargin-Length(title)) div 2), Title);
  1308.          PrintLn(dest,RightMargin-8,concat('Page ',i_str(PageNo,3)));
  1309.          PrintLn(Dest,0,'');
  1310.          PrintAt(dest,LeftMargin,'CONTACT');
  1311.          PrintAt(Dest,LeftMargin+25,'COMPANY');
  1312.          PrintLn(Dest,RightMargin-sizeof(Contact.Position),'POSITION');
  1313.          PrintLn(dest,LeftMargin, rpt('-',RightMargin-LeftMargin));
  1314.        end;
  1315.        If (NewPerson) or (PageLength = -1) then
  1316.          Printat(Dest,Leftmargin,concat(DelimStrt,Trimmed(Person.LName),', ',
  1317.          Trimmed(Person.FName),' ',Trimmed(Person.MName),Delimfnsh));
  1318.        if tfiletype>1 then colpos := 0 else colpos := 25;
  1319.        Printat(Dest,LeftMargin+colpos,concat(delimstrt,Company.Name,delimfnsh));
  1320.        Printat(Dest,RightMargin-sizeof(Contact.Position),
  1321.                     concat(delimstrt,Trimmed(Contact.Position),delimfnsh));
  1322.        println(dest,0,'');
  1323.      { reset data }
  1324.        NewPerson := False;
  1325.        DBase.NextAssoc(PersonData);
  1326.        if Company.Code = OldCode then
  1327.        begin
  1328.          DBase.Next;
  1329.          DBase.Associate(PersonData);
  1330.          OldCode := Company.Code;
  1331.          NewPerson := True;
  1332.        end;
  1333.      end;
  1334.      If (NewPerson) or (PageLength = -1) then
  1335.        Printat(Dest,Leftmargin,concat(DelimStrt,Trimmed(Person.LName),', ',
  1336.        Trimmed(Person.FName),' ',Trimmed(Person.MName),Delimfnsh));
  1337.      if tfiletype>1 then colpos := 0 else colpos := 25;
  1338.      Printat(Dest,LeftMargin+colpos,concat(delimstrt,Company.Name,delimfnsh));
  1339.      Printat(Dest,RightMargin-sizeof(Contact.Position),
  1340.                   concat(delimstrt,Trimmed(Contact.Position),delimfnsh));
  1341.      println(dest,0,'');
  1342.      formfeed(dest,Device);
  1343.    
  1344.    
  1345.                                         MMGRRPTS.PAS LISTING  PAGE  23   
  1346.    
  1347.    
  1348.      if Device = 'CON'then
  1349.      begin
  1350.        restore_Scrn_Rgn(1,1,80,25,@scrn);
  1351.        RestoreWindow(w);
  1352.      end
  1353.      else
  1354.        printingmsg.hide;
  1355.      close(dest);
  1356.      DBase.ClearRelations;
  1357.    NoPrint:
  1358.      pophelp;
  1359.    end;
  1360.    
  1361.    end. { Unit MMgrRpts }
  1362.