Ofs
Jump to navigation
Jump to search
Returns the offset of a specified object.
- Declaration
function Ofs(X): Word;
- Target
- Windows, Real, Protected
- Remarks
- X is any variable, or a procedure or function identifier. The result of type Word is the offset part of the address of X.
Sample Code
{CSeg.PAS} {Sample code for the CSeg, DSeg, SSeg, SPtr, Ofs, and Seg functions.} { For Windows: } { uses WinCrt; } procedure WriteHexWord(w: Word); const hexChars: array [0..$F] of Char = '0123456789ABCDEF'; begin Write(hexChars[Hi(w) shr 4], hexChars[Hi(w) and $F], hexChars[Lo(w) shr 4], hexChars[Lo(w) and $F]); end; var i: Integer; begin Write('The current code segment is $'); WriteHexWord(CSeg); Writeln; Write('The global data segment is $'); WriteHexWord(DSeg); Writeln; Write('The stack segment is $'); WriteHexWord(SSeg); Writeln; Write('The stack pointer is at $'); WriteHexWord(SPtr); Writeln; Write('i is at offset $'); WriteHexWord(Ofs(i)); Write(' in segment $'); WriteHexWord(Seg(i)); end.