Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Mark Morgan Lloyd
Jonas Maebe wrote: On 30 Apr 2011, at 14:30, Rainer Stratmann wrote: In Turbopascal it was possible with offs() type rectype = record var1 : longint; var2 : longint; var3 : boolean; end; var o : longint; recvar : rectype; o := offs( recvar.var1 ); // --> 0 That's incorrect. In TP, Ofs(

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Rainer Stratmann
Am Saturday 30 April 2011 15:15:21 schrieb Florian Klämpfl: > > o := PtrUInt( @recvar.var1 ) - PtrUInt( @recvar ); > > o := PtrIUnt( @recvar.var2 ) - PtrUInt( @recvar ); > > o := PtrInUt( @recvar.var3 ) - PtrUInt( @recvar ); > > Actually even > o := PtrUInt(@(rectype(nil^).var1))); > is possible.

RE : [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Ludo Brands
.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Jonas Maebe Envoyé : samedi 30 avril 2011 15:28 À : FPC-Pascal users discussions Objet : Re: [fpc-pascal] How to get the offset of a record On 30 Apr 2011, at 15:20, Rainer Stratmann wrote: > Am Saturday 30 April 201

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Rainer Stratmann
Am Saturday 30 April 2011 15:28:03 schrieb Jonas Maebe: > On 30 Apr 2011, at 15:20, Rainer Stratmann wrote: > > Am Saturday 30 April 2011 15:16:08 schrieb Jonas Maebe: > >> That's incorrect. In TP, Ofs(recvar.var1) (with one "f") returns the > >> offset in the segment that contains the "recvar" var

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Jonas Maebe
On 30 Apr 2011, at 15:20, Rainer Stratmann wrote: > Am Saturday 30 April 2011 15:16:08 schrieb Jonas Maebe: >> That's incorrect. In TP, Ofs(recvar.var1) (with one "f") returns the offset >> in the segment that contains the "recvar" variable. It does not return the >> relative offset of the field

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Rainer Stratmann
Am Saturday 30 April 2011 15:16:08 schrieb Jonas Maebe: > On 30 Apr 2011, at 14:30, Rainer Stratmann wrote: > > In Turbopascal it was possible with offs() > > > > type > > rectype = record > > var1 : longint; > > var2 : longint; > > var3 : boolean; > > end; > > > > var > > o : longint; > > recva

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Jonas Maebe
On 30 Apr 2011, at 14:30, Rainer Stratmann wrote: > In Turbopascal it was possible with offs() > > type > rectype = record > var1 : longint; > var2 : longint; > var3 : boolean; > end; > > var > o : longint; > recvar : rectype; > > o := offs( recvar.var1 ); // --> 0 That's incorrect. In TP

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Rainer Stratmann
Am Saturday 30 April 2011 14:54:22 schrieb Aleksa Todorovic: > On Sat, Apr 30, 2011 at 14:30, Rainer Stratmann > > wrote: > > In Turbopascal it was possible with offs() > > > > type > >  rectype = record > >  var1 : longint; > >  var2 : longint; > >  var3 : boolean; > >  end; > > > > var > >  o :

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Florian Klämpfl
> o := PtrUInt( @recvar.var1 ) - PtrUInt( @recvar ); > o := PtrIUnt( @recvar.var2 ) - PtrUInt( @recvar ); > o := PtrInUt( @recvar.var3 ) - PtrUInt( @recvar ); Actually even o := PtrUInt(@(rectype(nil^).var1))); is possible. ___ fpc-pascal maillist - fp

Re: [fpc-pascal] How to get the offset of a record

2011-04-30 Thread Aleksa Todorovic
On Sat, Apr 30, 2011 at 14:30, Rainer Stratmann wrote: > In Turbopascal it was possible with offs() > > type >  rectype = record >  var1 : longint; >  var2 : longint; >  var3 : boolean; >  end; > > var >  o : longint; >  recvar : rectype; > >  o := offs( recvar.var1 );  // --> 0 >  o := offs( recv