home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / pascal / 6484 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  1.1 KB

  1. Path: sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!hamblin.math.byu.edu!yvax.byu.edu!cunyvm!psuvm!f0o
  2. Newsgroups: comp.lang.pascal
  3. Subject: Comparing record types
  4. Message-ID: <92316.095144F0O@psuvm.psu.edu>
  5. From: <F0O@psuvm.psu.edu>
  6. Date: Wed, 11 Nov 1992 09:51:44 EST
  7. Organization: Penn State University
  8. Lines: 30
  9.  
  10. Hi!
  11.  
  12.    Take a look at the following example program:
  13.  
  14.  
  15. Type
  16. TPoint = Record
  17.    X, Y: Integer;
  18. End;
  19.  
  20. Var
  21.    P1, P2: TPoint;
  22.  
  23.  
  24. Begin
  25.    P1.X := 10; P1.Y := 20;
  26.    P2 := P1;
  27.    If (P1 = P2) then Writeln('Equal');     { This line is incorrect }
  28. End.
  29.  
  30.    When I run the program, I get the message, 'Operand types do not
  31. match operator'.
  32.    P1 and P2 are two variables of the same record type.  Now you can
  33. directly assign one record to another, as long as they are the same type.
  34. If there some simple way to compare P1 and P2 to see if they are equal,
  35. without having to check each field for equality in my code?
  36.    I was hoping I could say If (P1 = P2) then ..., but this does not
  37. work.  Does anyone know of some trick so I can easily compare records?
  38.  
  39.                                                          [Tim]
  40.