Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ukma!kherron From: kherron@ms.uky.edu (Kenneth Herron) Newsgroups: comp.lang.pascal Subject: Re: Turbo Pascal absolute variables crossing units Keywords: absolute variables units Borland Turbo Pascal TP4.0 Message-ID: <13784@s.ms.uky.edu> Date: 22 Jan 90 16:27:08 GMT References: <3757@mit-caf.MIT.EDU> <2013@rwthinf.UUCP> Reply-To: kherron@ms.uky.edu (Kenneth Herron) Organization: U of Kentucky, Mathematical Sciences Lines: 48 In episode <2013@rwthinf.UUCP>, we heard pmk@cip-s01.UUCP (Michael Keukert) say: |In article <3757@mit-caf.MIT.EDU> the@mit-caf.UUCP (Siang-Chun The) writes: |> |> status : integer absolute inner.stat; | |Try instead: | | UNIT outer; | | INTERFACE | | CONST status:INTEGER = inner.stat; | | IMPLEMENTATION | |Doing this, you declare outer.status as a typed constant which means, |this is a "normal" variable but with a defined value within the code. | |ABSOLUTE is only valid with a memory-adress for example | | VAR somewhere_in_memory ABSOLUTE $c000:0000; | |which means, that the variable somewhere_in_memory contains always |the value in memory-cell $c000:000. | |OK? BZZT! Wrong, but thanks for playing... Your alternative suggestion won't work. Inner.stat is a variable, so at compile-time, when status is initialized, inner.stat has no value. Further, any changes to inner.stat as the program runs would not be reflected in status. Your example would work if the declaration made status use the same memory location as inner.stat. Your comments about ABSOLUTE are also wrong. You can give a variable name in place of the address, in which case the new variable being defined is aliased to the same memory location as the original variable. This is, in fact, the correct way of doing what you seem to be trying in your counterexample (except that evidently it doesn't work across unit boundaries). Disclaimer: The latest version I have programming experience with is TP 4.0; from what I've heard about the later versions, the above facts should still be correct. Kenneth Herron