Calculate field offset in a typed record

From: Rudi Loos (loos_at_intekom.co.za)
Date: 12/29/03

  • Next message: KLinZ: "Re: Calculate field offset in a typed record"
    Date: Mon, 29 Dec 2003 02:42:00 +0200
    
    

    Hi

    I have looked on the web and in the groups but to no avail. Can anyone
    explain how I can calculate the offset of a field with respect to the
    record. e.g.:

     TMyrecord = packed record
        Field1 : Integer;
        Field2 : Array [0..25] of byte;
        ......
        Field24 : Word;
        Field25 : String[13]
     end;

    I would like to calculate the offset to field24 with respect to MyRecord.
    I have large records that I use to communicate with an electronic device and
    want to pass an address and byte count so that I will only need to read 2
    bytes at address Field24.
    I tried to subtract the pointers but I get an error "operation not
    applicable"

    Thanks to everyone in the group that continually provides help.

    Rudi


  • Next message: KLinZ: "Re: Calculate field offset in a typed record"

    Relevant Pages

    • Re: Calculate field offset in a typed record
      ... >I would like to calculate the offset to field24 with respect to MyRecord. ... >I have large records that I use to communicate with an electronic device and ...
      (comp.lang.pascal.delphi.misc)
    • Re: Formula Too Long Issue
      ... of 0 ...hence subtract one. ... can learn more about offset in the formula. ... Try making the cell references in the formula shorter ...
      (microsoft.public.excel.misc)
    • Re: transport a C pointer through Tcl
      ... Andreas Otto wrote: ... I've taken a different approach lately with extension pointers. ... In other words I store an int offset in each Tcl_Obj, ... It's also faster than Tcl's hash table, ...
      (comp.lang.tcl)
    • Re: help about pointer copy
      ... > change and therefor the pointers/iterators become invalid or does it mean ... > that the order and offset of the vector-elements keep the same when adding ... Any pointers to the old block would now be indeterminate (so it could ... implemented as pointers, rather than offsets, so the iterators ...
      (comp.lang.cpp)
    • Re: Win32 SEH question
      ... .COD file will have the offset as the first bit on each assembler line. ... your offending instruction address, subtract 401000, look in your map file to find the function where that offset would ... >> EIP will show you exactly the offending instruction. ... > to maintain a map file but how do I maintain a list file in Visual C++ 6.0? ...
      (microsoft.public.win32.programmer.kernel)