Technical Notes Database TN964D.txt NORMALIZING POINTERS Category :Pascal Platform :All Product :Turbo Pascal 4.0+ Description: Q. How do I normalize a pointer in Turbo Pascal? A. When you allocate a pointer, it is already normalized. So, if you're SURE that you won't be making the offset greater than 64K, you can skip the normalizing step. PROCEDURE Normalize(VAR P); VAR pt : Pointer ABSOLUTE P; BEGIN Pt := Ptr(seg(pt^) + (ofs(pt^) DIV 16), ofs(pt^) MOD 16); END; You CAN perform pointer arithmetic, if you're desperate to do "C things" in Pascal. Just normalize the pointer (maximize segment, minimize offset), typecast it to a LongINt, and do your math. E.g. Normalize(recptr); Inc(LongInt(recptr), SizeOf(rec)); where recptr is a pointer to a record, and rec is the record variable. Reference: 7/16/98 4:35:38 PM
Last Modified: 01-SEP-99