program mail ;

  { RELIANCE MAILING LIST, Version 2.0.

    Copyright (c) 1986 William Meacham, All Rights Reserved

    William Meacham
    1004 Elm Street
    Austin, Tx  78703

    Revised:  3/11/86 }

{ ----------------------------------------------------------- }

{$C-,V-}

const copyright : string[69] =
   'RELIANCE MAILING LIST VERSION 2.0 COPYRIGHT (c) 1986 WILLIAM MEACHAM' ;
    version = 2.0 ;

  { TURBO ACCESS constants }
    MaxDataRecSize = 216 ;
    MaxKeyLen      = 15 ;
    PageSize       = 24 ;
    Order          = 12 ;
    PageStackSize  = 8 ;
    MaxHeight      = 5 ;

{$i a:access.box }
{$i a:getkey.box }
{$i a:addkey.box }
{$i a:delkey.box }
{$i io20.inc }
{$i maildate.inc }
{$i mailglob.inc }

{ ------------------------------------------------------------------------ }
{                      functions and procedures                            }
{ ------------------------------------------------------------------------ }

function exists (filename : str14) : boolean ;
  { test to see if file exists }
var
    infile : file ;
begin
    assign (infile,filename) ;
    {$i-} reset(infile) {$i+} ;
    exists := (ioresult = 0) ;
    close (infile)
end ; { function exists }

{------------------------------------------------------------- }

function files_exist : boolean ;
begin
    files_exist := exists(scr_fname) and exists(mf_fname)
               and exists(ix1_fname) and exists(ix2_fname)
end ;  { function files_exist }

{ ----------------------------------------------------------- }

{$i mroot1.inc -- miscellaneous }

{ ----------------------------------------------------------- }

{$i mroot2.inc -- clear_master, display_master, input_master, select }

{ ---- BEGIN OVERLAY AREA 000 ------------------------------- }

{$i minit.inc -- procs initialize and reset_disks }

{ ----------------------------------------------------------- }

{$i msetup.inc -- proc set_up }

{ ----------------------------------------------------------- }

{$i maddetc.inc -- procs add, change, record_contributions, delete_name }

{ ----------------------------------------------------------- }

{$i mprint.inc -- proc print (list, labels) }

{ ----------------------------------------------------------- }

{$i mailmerg.inc -- proc make_mailmerge_file }

{ ---- END OVERLAY AREA 000 --------------------------------- }

begin { -------- MAIN -------- }

    initialize ;
    repeat
        paint_screen (0) ;     { Main menu }
        repeat
            fld := 1 ;
            choice := 0 ;
            read_int (choice,1, 31,21) ;
            if fld < 1 then choice := 0 ;
            if fld = maxint then
              begin
                write_str (' ',31,21) ;
                write_str ('QUIT NOW? (Y/N)',26,23) ;
                read_yn (OK,42,23) ; { global, in Access.box }
                if not OK then
                  begin
                    fld := 1 ;
                    choice := 0 ;
                    clrline (26,23)
                  end
              end ;
        until (choice in [1 .. 9]) or (fld = maxint) ;
        if not (fld = maxint) then
            case choice of
              1: set_up ;
              2: do_name (add) ;
              3: do_name (change) ;
              4: do_name (del_rec) ;
              5: do_name (contribution) ;
              6: print (list) ;
              7: print (labels) ;
              8: make_mailmerge_file ;
              9: reset_disks
            else
                 beep
            end  { case }
    until fld = maxint ;
    clrscr ;
    write_str ('Thank you for using the Reliance Mailing List program.',12,5) ;
    write_str ('Don''t forget to back up your data files! ',12,7) ;
    write_str ('If you find this program useful, please make a contribution',12,10) ;
    write_str ('to encourage me to write some more.  Thanks!',12,11) ;
    write_str ('Bill Meacham',34,13) ;
    write_str ('1004 Elm Street',32,14) ;
    write_str ('Austin, Tx  78703',31,15)
end.
