home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / pascal / 4857 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  2.1 KB

  1. Path: sparky!uunet!zephyr.ens.tek.com!vice!bobb
  2. From: bobb@vice.ICO.TEK.COM (Bob Beauchaine)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: Apparent bug in TurboVision TInputLine
  5. Message-ID: <10165@vice.ICO.TEK.COM>
  6. Date: 14 Aug 92 18:41:57 GMT
  7. References: <S2861785.92Aug14102443@techunix.technion.ac.il|
  8. Organization: Tektronix, Inc., Beaverton,  OR.
  9. Lines: 46
  10.  
  11.  
  12. In article <S2861785.92Aug14102443@techunix.technion.ac.il| s2861785@techunix.technion.ac.il (Alon Ziv) writes:
  13. |While writing some TVision code, I came up with some rather weird
  14. |behaviour in TInputLine's methods. It would seem that TInputLine uses
  15. |DataSize in some unexpected ways, so, for instance, if you overload it
  16. |to provide (say) LongInt data, and your SetData looks like
  17. |
  18. |    procedure TInputLong.SetData(var Rec);
  19. |      {-Set data in a TInputLong (**BUGGY**) }
  20. |
  21. |      var
  22. |        RecAsLongInt: LongInt
  23. |                      absolute Rec;
  24. |        S: String;
  25. |
  26. |      begin {SetData}
  27. |        Str(RecAsLongInt: MaxLen, S);
  28. |        TInputLine.SetData(S);
  29. |      end; {TInputLong.SetData}
  30. |
  31. |(Yes, I know this is a little silly to do... Actually, what I had was
  32. | a 'grandchild' of TInputLine using its parent's method, which used
  33. | TInputLine's... )
  34. |
  35. |The above code won't work, because TInputLong.DataSize returns
  36. |4=SizeOf(LongInt) and causes TInputLine.SetData to copy just 4 bytes
  37. |from S (which probably won't be right...)
  38. |
  39.   Your fundamental mistake is that you are storing your long integer
  40.   as a string, not a longint.  I assume (w/o a code reference) that
  41.   you overrode TInputLine's Datasize method to return 4, the size of
  42.   a long integer.  If so, you would then need to store the long
  43.   integer as a longint, not a string.  You're not being consistent
  44.   in your use of data types.  
  45.  
  46.   I have created descendents of TInputLine for long integers, and
  47.   encountered none of the problems you are referring to.
  48.  
  49. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 
  50.  
  51. Bob Beauchaine bobb@vice.ICO.TEK.COM 
  52.  
  53. C: The language that combines the power of assembly language with the 
  54.    flexibility of assembly language.
  55.  
  56. Real friends don't let friends use UNIX.
  57.