home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / biseqin.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.4 KB  |  69 lines

  1.                                        -- Chapter 22 - Program 2
  2. with Text_IO;
  3. use Text_IO;
  4. with Sequential_IO;
  5.  
  6. procedure BiSeqIn is
  7.  
  8.    type MY_REC is
  9.       record
  10.          Age     : INTEGER;
  11.          Sex     : CHARACTER;
  12.          Initial : CHARACTER;
  13.       end record;
  14.  
  15.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  16.    use Int_IO;
  17.    package Seq_IO is new Sequential_IO(MY_REC);
  18.    use Seq_IO;
  19.  
  20.    Myself     : MY_REC;
  21.    My_In_File : Seq_IO.FILE_TYPE;
  22.  
  23. begin
  24.  
  25.    Open(My_In_File, In_File, "NAMEFILE.TXT");
  26.  
  27.    for Index in 1..100 loop
  28.       Read(My_In_File, Myself);
  29.       if Myself.Age >= 82 then
  30.          Put("Record number");
  31.          Put(Myself.Age);
  32.          Put(" ");
  33.          Put(Myself.Sex);
  34.          Put(" ");
  35.          Put(Myself.Initial);
  36.          New_Line;
  37.       end if;
  38.    end loop;
  39.  
  40.    Close(My_In_File);
  41.  
  42. end BiSeqIn;
  43.  
  44.  
  45.  
  46.  
  47. -- Result of Execution
  48.  
  49. -- Record number    82 M X
  50. -- Record number    83 M X
  51. -- Record number    84 M X
  52. -- Record number    85 M X
  53. -- Record number    86 M X
  54. -- Record number    87 M X
  55. -- Record number    88 M X
  56. -- Record number    89 M X
  57. -- Record number    90 M X
  58. -- Record number    91 M X
  59. -- Record number    92 M X
  60. -- Record number    93 M X
  61. -- Record number    94 M X
  62. -- Record number    95 M X
  63. -- Record number    96 M X
  64. -- Record number    97 M X
  65. -- Record number    98 M X
  66. -- Record number    99 M X
  67. -- Record number   100 M X
  68.  
  69.