Program GetAdr; {$nomain} {$NOwalkback} { Version 1.0 File:[22,310]GETADR.PAS Author: Jim Bostwick 6-Oct-83 Last Edit: 23-JUN-1988 22:16:37 History: 23-JUN-1988 21:57:16 - JMB PA3UTL upgrade. } {*NOTE* This procedure uses a dummy procedure header to fool Pascal into passing it the value of a global symbol. The dummy procedure header follows - it will be extracted by EXTCRE. } { Function GetAdr( procedure p):Word ;External; } {*USER* Returns the value of global symbol "p". "P" must be declared as an external procedure in the calling program, as follows: Procedure P;External; -- "P" is the global symbol in question begin i := GetAdr(p); -- i is set to global value of symbol "p" end } %INCLUDE 'PAS$EXT:General.typ'; {*WIZARD* Here follows the 'real' declaration of Getadr. The whole trick is to make the external treat the address of 'procedure' "P" as a simple integer. However, because pascal passes a thing called the 'dynamic link' along with procedures, we must also define a dummy variable to keep the stack aligned properly. } Function GetAdr(foo,p:word):Word ;External; Function GetAdr; CONST debug = false; BEGIN GetAdr := p; if debug then writeln('getadr: p=',p:-8,' foo=',foo:-8) end;