home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug117.arc / PACCTS.LBR / ACCTS2.IQC / ACCTS2.INC
Text File  |  1979-12-31  |  5KB  |  163 lines

  1. {This is the second INCLUDE file to ACCTS.PAS}
  2.  
  3.  
  4. Overlay Procedure StartLedger;
  5. Var
  6.    J,Z : Byte; A : Char;
  7.  
  8. Begin
  9.      Gotoxy(20,6); Write('Enter file name: ');
  10.      BufLen:=14; Read(FileName);
  11.      If Pos('.',FileName) = 0 then
  12.           FileName:=FileName + '.ACC' else
  13.      Begin
  14.           Delete(FileName,Pos('.',FileName),4);
  15.           FileName:=FileName + '.ACC'
  16.      end;
  17.      For J:=1 to 20 do
  18.          Accounts[J]:='';
  19.      LastRec:=-1; Clear(6,6); Gotoxy(1,6);
  20.      Write('Enter Account names (Max 20). Press <ESC> to stop entries:');
  21.      K:=0;
  22.      While (K<21) and (A <> #27) do
  23.      Begin
  24.           J:=1; K:=K+1;
  25.           If K<18 then Gotoxy(20,K+6) else
  26.           Gotoxy(50,K-11); Write('--> ');
  27.           Accounts[K]:='';
  28.           Repeat
  29.                 Read(Kbd,A); A:=UpCase(A); Write(A);
  30.                 Accounts[K]:=Accounts[K] + A;
  31.                 If J=1 then Code[K]:=A;
  32.                 J:=J+1
  33.           Until (A=#13) or (A=#27);
  34.           Delete(Accounts[K],J-1,1);
  35.           Code[K]:=Char(Ord(Code[K])+32);
  36.           If K>1 then
  37.           Begin
  38.                For J:=K downto 2 do
  39.                If Code[K]=Code[J-1] then Code[K]:=Char(Ord(Code[K])-32);
  40.           end;
  41.      end;
  42.      Assign(AccFile,FileName);
  43.      Rewrite(AccFile); EndCode:=K-1;
  44.      For J:=1 to EndCode do
  45.      Writeln(AccFile,Accounts[J]);
  46.      Close(AccFile);
  47.      Delete(FileName,Pos('.',FileName),4);
  48.      FileName:=FileName + '.PAC';
  49.      For K:=1 to Length(FileName) do
  50.          FileName[K]:=UpCase(FileName[K]);
  51.      Assign(EntryFile, FileName);
  52.      Rewrite(EntryFile);
  53.      Clear(3,23); Gotoxy(36,1);
  54.      LOwVideo; Write(FileName); NormVideo;
  55. end;
  56.  
  57. Overlay Procedure Enter;
  58. Var
  59.    Chr : Char;
  60.    Temp, Temp1 : Julian;
  61.    ValDate : Boolean;
  62.    Day, Month, Year, Result : Integer;
  63.    A, B, C : Byte;
  64.  
  65. Const
  66.      Duration : Array [1..12] of Byte = (31,29,31,30,31,30,
  67.                                          31,31,30,31,30,31);
  68.  
  69. Begin
  70.      Gotoxy(1,5); Write('ACCOUNTS:');
  71.      A:=15; B:=5; C:=1;
  72.      While C<=EndCode do
  73.      Begin
  74.           If A>71 then
  75.           Begin
  76.                A:=1; B:=B+1;
  77.           end;
  78.           Gotoxy(A,B); Write(Code[C],'-',Accounts[C]);
  79.           A:=A + 14; C:=C + 1;
  80.      end; {While C}
  81.      Writeln; Line(80,#45); LastRec:=LastRec + 1;
  82.      If LastRec > MaxRec then
  83.      Begin
  84.           LastLine('Record capacity exceeded: to abort entries');
  85.           Clear(5,9); Exit
  86.      end;
  87.      Gotoxy(5,12); Write('Record no.');
  88.      If Changing then Write(K:4,'  -  ') else
  89.         Write(LastRec:4,'  -  ');
  90.      Write('Date (ddmmyy): ______'); Gotoxy(39,12);
  91.      Temp:=''; ValDate:=False;
  92.      While (Not ValDate) do
  93.      Begin
  94.           Message:='Invalid date: to start again';
  95.           K:=1; Chr:='~';
  96.           While (Chr <> ^M) and (K<7) do
  97.           Begin
  98.                Repeat
  99.                      Read(Kbd,Chr)
  100.                Until Chr in ['0'..'9',^M];
  101.                Write(Chr); K:=K + 1;
  102.                Temp:=Temp+Chr
  103.           end; {While Chr}
  104.           If Chr=^M then
  105.           Begin
  106.                If LastRec=0 then LastLine(Message) else
  107.                Begin
  108.                     Temp:='';
  109.                     Temp1:=Ledger[Pred(LastRec)].Date;
  110.                     Temp:=Copy(Temp1,5,2);
  111.                     Temp:=Temp+Copy(Temp1,3,2);
  112.                     Temp:=Temp+Copy(Temp1,1,2)
  113.                end;
  114.           end; {If Chr}
  115.           Temp1:=Copy(Temp,1,2); Val(Temp1,Day,Result);
  116.           Temp1:=Copy(Temp,3,2); Val(Temp1,Month,Result);
  117.           Temp1:=Copy(Temp,5,2); Val(Temp1,Year,Result);
  118.           If (Day > Duration [Month]) or (Month > 12) or
  119.           (Year < 86) then
  120.           Begin
  121.                LastLine(Message);
  122.                Temp:=''; Gotoxy(39,12); ClrEol;
  123.           end else ValDate:=True
  124.      end; {While not ValDate}
  125.      Gotoxy(39,12); ClrEol;
  126.      Write(Copy(Temp,1,2),'/');
  127.      Write(Copy(Temp,3,2),'/',Copy(Temp,5,2));
  128.      With Ledger[LastRec] do
  129.      Begin
  130.           Date:=Copy(Temp,5,2)+Copy(Temp,3,2);
  131.           Date:=Date+Copy(Temp,1,2); A:=0;
  132.           Repeat
  133.                 Gotoxy(24,14); Write('Account code: ');
  134.                 If EndCode=1 then
  135.                 Begin
  136.                      Write(Code[1],' - ',Accounts[1]);
  137.                      Accode:=Code[1]; A:=1; end else
  138.                 Begin
  139.                      Read(Kbd,Accode);
  140.                      For K:=1 to EndCode do
  141.                      Begin
  142.                           If Accode=Code[K] then
  143.                           Begin
  144.                                Write(Accode,' - ',Accounts[K]);
  145.                                A:=1;
  146.                           end;
  147.                      end;
  148.                 end; {If EndCode}
  149.           Until A=1;
  150.           Gotoxy(24,16); Write('Details: '); Line(30,#95);
  151.           Gotoxy(33,16); Read(Descr);
  152.           Gotoxy(24,18); Write('Amount: ');
  153.           Read(Amount);
  154.           If Ch='E' then Amount:= -Amount;
  155.      end; {With Ledger}
  156.      If (not Changing) and (LastRec > 0) then Sort;
  157.      Clear(5,18)
  158. end;
  159.  
  160.  
  161.  
  162.  
  163.