Forum > General

Referencing a label

(1/3) > >>

440bx:
Hello,

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.

engkin:
Try @Mark.

440bx:

--- 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.

engkin:
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.

440bx:

--- Quote from: engkin on May 01, 2021, 01:51:52 am ---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.

--- End quote ---
I appreciate the help.  FPC works as it should.  There is nothing esoteric about a label but, Delphi 2 seems to treat it as a "sacred object".


--- Quote from: jamie on May 01, 2021, 01:54:04 am ---Hmm, I find that hard to believe the @ does not work with D2 ?

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

--- End quote ---
Hard to believe but, believe it.  I hadn't tried "Addr" but, tried it after you suggested it and, no luck. 

Thank you for the suggestion.

Navigation

[0] Message Index

[#] Next page

Go to full version