home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zephyr.ens.tek.com!vice!bobb
- From: bobb@vice.ICO.TEK.COM (Bob Beauchaine)
- Newsgroups: comp.lang.pascal
- Subject: Re: Apparent bug in TurboVision TInputLine
- Message-ID: <10165@vice.ICO.TEK.COM>
- Date: 14 Aug 92 18:41:57 GMT
- References: <S2861785.92Aug14102443@techunix.technion.ac.il|
- Organization: Tektronix, Inc., Beaverton, OR.
- Lines: 46
-
-
- In article <S2861785.92Aug14102443@techunix.technion.ac.il| s2861785@techunix.technion.ac.il (Alon Ziv) writes:
- |While writing some TVision code, I came up with some rather weird
- |behaviour in TInputLine's methods. It would seem that TInputLine uses
- |DataSize in some unexpected ways, so, for instance, if you overload it
- |to provide (say) LongInt data, and your SetData looks like
- |
- | procedure TInputLong.SetData(var Rec);
- | {-Set data in a TInputLong (**BUGGY**) }
- |
- | var
- | RecAsLongInt: LongInt
- | absolute Rec;
- | S: String;
- |
- | begin {SetData}
- | Str(RecAsLongInt: MaxLen, S);
- | TInputLine.SetData(S);
- | end; {TInputLong.SetData}
- |
- |(Yes, I know this is a little silly to do... Actually, what I had was
- | a 'grandchild' of TInputLine using its parent's method, which used
- | TInputLine's... )
- |
- |The above code won't work, because TInputLong.DataSize returns
- |4=SizeOf(LongInt) and causes TInputLine.SetData to copy just 4 bytes
- |from S (which probably won't be right...)
- |
- Your fundamental mistake is that you are storing your long integer
- as a string, not a longint. I assume (w/o a code reference) that
- you overrode TInputLine's Datasize method to return 4, the size of
- a long integer. If so, you would then need to store the long
- integer as a longint, not a string. You're not being consistent
- in your use of data types.
-
- I have created descendents of TInputLine for long integers, and
- encountered none of the problems you are referring to.
-
- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
-
- Bob Beauchaine bobb@vice.ICO.TEK.COM
-
- C: The language that combines the power of assembly language with the
- flexibility of assembly language.
-
- Real friends don't let friends use UNIX.
-