home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug141.arc / PACCTS.LBR / ACCTS1.IQC / ACCTS1.INC
Text File  |  1979-12-31  |  6KB  |  226 lines

  1. {This is the first INCLUDE file to ACCTS.PAS}
  2.  
  3.  
  4. Overlay Procedure SingleAccount;
  5. Var
  6.    A,B,C : Integer;
  7.    Index : Char;
  8.    Flag : Boolean;
  9.  
  10. Begin
  11.      Gotoxy(1,7); Write('ACCOUNTS:');
  12.      A:=15; B:=7; C:=1;
  13.      While C<=EndCode do
  14.      Begin
  15.           If A>71 then
  16.           Begin
  17.                A:=1; B:=B + 1;
  18.           end;
  19.           Gotoxy(A,B); Write(Code[C],'-',Accounts[C]);
  20.           A:=A + 14; C:=C + 1;
  21.      end; {While C}
  22.      Writeln; Line(80,#45);
  23.      Repeat
  24.            Gotoxy(20,B+2); Write('Select Account code: ');
  25.            Read(Kbd,Index); Flag:=False;
  26.            For A:=1 to EndCode do
  27.            Begin
  28.                 If Index=Code[A] then
  29.                 Begin
  30.                      C:=A; Write(Index); Flag:=True;
  31.                 end;
  32.            end;
  33.      Until Flag=True;
  34.      If not Shown then
  35.      Begin
  36.           LastLine(Message); Close(Dev);
  37.           Assign(Dev,'LST:');Reset(Dev);
  38.      end else
  39.      Begin
  40.           Assign(Dev,'CON:'); Reset(Dev);
  41.           Clear(3,23); Gotoxy(1,3)
  42.      end;
  43.      Headings; AccTitle(C); Bal:=0;
  44.      For A:=0 to LastRec do
  45.      If Found(A,C) then ProcessLine(A);
  46.      AccBal; Close(Dev);
  47.      If Shown then LastLine(Message);
  48.      Clear(3,23);
  49. end;
  50.  
  51. Overlay Procedure AllAccounts;
  52. Var
  53.    A,B : Integer;
  54.    Flag : Boolean;
  55.  
  56. Begin
  57.      If not Shown then
  58.      Begin
  59.           LastLine(Message);
  60.           Assign(Dev,'LST:'); Reset(Dev);
  61.      end else
  62.      Begin
  63.           Assign(Dev,'CON:'); Reset(Dev);
  64.           Clear(3,23); Gotoxy(1,3)
  65.      end;
  66.      Flag:=True; Bal:=0; Headings;
  67.      For B:=1 to EndCode do
  68.      Begin
  69.           For A:=0 to LastRec do
  70.           Begin
  71.                If Found(A,B) then
  72.                Begin
  73.                     If Flag = True then AccTitle(B);
  74.                     ProcessLine(A);
  75.                     Flag:=False
  76.                end;
  77.           end;
  78.           If Flag=False then AccBal;
  79.           Flag:=True
  80.      end;
  81.      Close(Dev);
  82.      If Shown then LastLine(Message);
  83.      Clear(3,23);
  84. end;
  85.  
  86. Overlay Procedure AccountsBalance;
  87. Var
  88.    A,B : Integer;
  89.  
  90. Begin
  91.      If not Shown then
  92.      Begin
  93.           LastLine(Message);
  94.           Assign(Dev,'LST:'); Reset(Dev);
  95.      end else
  96.      Begin
  97.           Assign(Dev,'CON:'); Reset(Dev);
  98.           Clear(3,23); Gotoxy(1,3);
  99.      end;
  100.      Total:=0; Bal:=0; Headings;
  101.      For B:=1 to EndCode do
  102.      Begin
  103.           For A:=0 to LastRec do
  104.           If Found(A,B) then Bal:=Bal+Ledger[A].Amount;
  105.           CheckRow(Y); Write(Dev,'     ',Accounts[B]);
  106.           Pline(50-Length(Accounts[B]),#32);
  107.           If Bal<0 then
  108.           Begin
  109.                Write(Dev,'|',Abs(Bal):10:2,'|');
  110.                Pline(10,#32);
  111.                Writeln(Dev,'|');
  112.           end else
  113.           Begin
  114.                Write(Dev,'|'); Pline(10,#32);
  115.                Write(Dev,'|',Bal:10:2);
  116.                Writeln(Dev,'|');
  117.           end; {If Bal =>0}
  118.           Total:=Total+Bal; Bal:=0;
  119.      end; {For B}
  120.      CheckRow(Y); Pline(55,#32); Write(Dev,'+');
  121.      Pline(10,#45); Write(Dev,'+');
  122.      Pline(10,#45); Writeln(Dev,'+');
  123.      CheckRow(Y);
  124.      Pline(49,#32); Write(Dev,'Total |');
  125.      If Total < 0 then
  126.      Begin
  127.           Write(Dev,Abs(Total):10:2,'|');
  128.           Pline(10,#32);
  129.           Writeln(Dev,'|');
  130.      end else
  131.      Begin
  132.           Pline(10,#32);
  133.           Writeln(Dev,'|',Total:10:2,'|');
  134.      end;
  135.      Pline(55,#32); Pline(23,#61); Close(Dev);
  136.      If Shown then LastLine(Message);
  137.      Clear(3,23);
  138. end;
  139.  
  140. Overlay Procedure CashBook;
  141. Var
  142.    J:Integer;
  143.  
  144. Begin
  145.      If not Shown then
  146.      Begin
  147.           LastLine(Message);
  148.           Assign(Dev,'LST:'); Reset(Dev);
  149.      end else
  150.      Begin
  151.           Assign(Dev,'CON:'); Reset(Dev);
  152.           Clear(3,20); Gotoxy(1,3)
  153.      end;
  154.      Headings; Bal:=0;
  155.      For J:=0 to LastRec do ProcessLine(J);
  156.      AccBal; Close(Dev);
  157.      If Shown then LastLine(Message);
  158.      Clear(3,23);
  159. end;
  160.  
  161. Overlay Procedure Load;
  162. Var J : Byte;
  163.     A : Char;
  164.     Temp : AccName;
  165.  
  166. Begin
  167.      Gotoxy(20,6); Write('Enter file name: ');
  168.      BufLen:=14; Read(FileName);
  169.      If Pos('.',FileName)=0 then
  170.         FileName:=FileName + '.PAC';
  171.      For K:=1 to Length(FileName) do
  172.         FileName[K]:=UpCase(FileName[K]);
  173.      Assign(EntryFile,FileName);
  174.      {$I-}
  175.      Reset(EntryFile);
  176.      {$I+}
  177.      If IOresult<>0 then
  178.      Begin
  179.           Close(EntryFile);
  180.           LastLine('Could not find file.'); Halt
  181.      end;
  182.      Clear(6,6); LastRec:=0; Gotoxy(36,1);
  183.      LowVideo; Write(FileName); NormVideo;
  184.      While not EOF(EntryFile) do
  185.      Begin
  186.           Read(EntryFile,Ledger[LastRec]);
  187.           LastRec:=Succ(LastRec);
  188.       end;
  189.       Close(EntryFile); LastRec:=Pred(LastRec); FileName2:=FileName;
  190.       Delete(FileName2,Pos('.',FileName2),4);
  191.       FileName2:=FileName2 + '.ACC';
  192.       Assign(AccFile,FileName2);
  193.       Reset(AccFile);  K:=0;
  194.       While not EOF(AccFile) do
  195.       Begin
  196.            K:=K+1;
  197.            Readln(AccFile,Accounts[K]);
  198.            Temp:=Accounts[K]; A:=Temp[1];
  199.            Code[K]:=Char(Ord(A)+32);
  200.       end;
  201.       Close(AccFile); EndCode:=K;
  202.       If EndCode > 1 then
  203.       Begin
  204.            For K:=2 to EndCode do
  205.            Begin
  206.                 For J:=K downto 2 do
  207.                 If Code[K]=Code[J-1] then Code[K]:=Char(Ord(Code[K])-32);
  208.            end;
  209.       end;
  210. end;
  211.  
  212. Overlay Procedure Save;
  213.  
  214. Begin
  215.      Rewrite(EntryFile);
  216.      For K:=0 to LastRec do
  217.      Write(EntryFile,Ledger[K]);
  218.      Close(EntryFile);
  219. end;
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.