Forum > General

Referencing a label

(1/3) > >>


I want to get the address associated with a label but, I don't seem to get the syntax right.  I tried the following:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$APPTYPE CONSOLE} {$TYPEDADDRESS ON} program _LabelReference; uses  sysutils  ; {$ifdef VER90}type  DWORD    = longint;  PDWORD   = ^DWORD;   ptruint  = DWORD;{$endif}  label  Mark; begin  writeln;  writeln;   Mark:   writeln('  address of mark is : ', IntToHex(ptruint(Mark), 0));   writeln;  writeln;  writeln('press ENTER/RETURN to end this program');  readln;end.      which produces a compiler error. I also tried a few variations but none provided any joy.

Is there a way to get the address the label references ? and if the answer is yes, how it's done will be greatly appreciated.

Thank you.

Try @Mark.


--- Quote from: engkin on May 01, 2021, 01:34:43 am ---Try @Mark.

--- End quote ---
Thank you Engkin.  That works with FPC.  Unfortunately, it doesn't work with Delphi 2 (I don't know if it works or not with later versions.)

With Delphi 2, the only way I found was to use assembler.

Thank you again.

Unfortunately I don't known much about Delphi, but I see it works with $mode Delphi. I know it doesn't help as you already tested with Delphi 2.

Hmm, I find that hard to believe the @ does not work with D2 ?

anyways, did you try Addr(The Item of Interest ):Pointer;


[0] Message Index

[#] Next page

Go to full version