home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / pub / users / Harry / compilers / p3 / tst / records2.pcat < prev    next >
Text File  |  2005-10-24  |  1KB  |  34 lines

  1. (* testing records *)
  2.  
  3. program is
  4.     var i : integer := 0;
  5.     type Complex is record r: real; i : real; end;
  6.     type Pair is record first: Complex; second : Complex; end;
  7.     var c : Complex := Complex { r := 0.0; i := 0.0 };
  8.     var p : Pair := Pair { first := Complex { r := 0.0; i := 0.0 };
  9.                            second := Complex { r := 0.0; i := 0.0 } };
  10.     procedure print() is begin
  11.     write("    (", c.r, ", ", c.i, ")");
  12.     end;
  13. begin 
  14.     c.r := 1.0;
  15.     c.i := 0.0;
  16.     p.first := c;
  17.     c.r := 0.0;
  18.     c.i := 1.0;
  19.     p.second := c;
  20.     c := p.first;
  21.     write ("The first complex number should be (1.0, 0.0):");
  22.     print();
  23.     c := p.second;
  24.     write ("The second complex number should be (0.0, 1.0):");
  25.     print();
  26.     if p.first.r <> p.second.r then 
  27.     write ("and these two complex numbers are not equal!");
  28.     elseif p.first.i <> p.second.i then 
  29.     write ("and these two complex numbers are not equal!");
  30.     else
  31.     write ("and these two complex numbers are equal?");
  32.     end;
  33. end;
  34.