home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST1201.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-11-17  |  1.3 KB  |  41 lines

  1. Program Master;
  2.  
  3. Uses
  4.   CRT;
  5.  
  6. Const
  7.   FileName = 'F:\DATA.DAT';
  8.  
  9. Type
  10.   arType = Array [1..5] of Word;
  11.  
  12. Var
  13.   f : File Of arType;
  14.   a : arType;
  15.   ioErr : Word;
  16.  
  17. Begin
  18.   FillChar ( a, SizeOf ( a ), 0 );  { Initialize the array to 0 }
  19.   Assign ( f, FileName );
  20.   Rewrite ( f );                      { Create a brand new file }
  21.   Close ( f );
  22.   FileMode := 34;              { Access read/write - deny write }
  23.   Reset ( f );                                  { Open the file }
  24.   Repeat
  25.     Seek ( f, 0 );                  { Move to beginning of file }
  26.     Inc ( a[1] );                           { Change the values }
  27.     If ( a[1] mod 2 = 0 ) Then
  28.       Inc ( a[2] );                                   { " }
  29.     If ( a[1] mod 3 = 0 ) Then
  30.       Inc ( a[3] );                                   { " }
  31.     If ( a[1] mod 4 = 0 ) Then
  32.       Inc ( a[4] );                                   { " }
  33.     If ( a[1] mod 5 = 0 ) Then
  34.       Inc ( a[5] );                                   { " }
  35.     Write ( f, a );                         { Write to the file }
  36.     WriteLn ( a[1]:4, a[2]:4, a[3]:4, a[4]:4, a[5]:4 );
  37.     Delay ( 1000 );               { Slow down the file updating }
  38.   Until KeyPressed;                        { Stop if user input }
  39.   Close ( f );                                 { Close the file }
  40. End.
  41.