[comp.sys.mac.programmer] referencing pointers to resources in Lightspeed Pascal

) (03/18/88)

Following is some source code that obtains the FKEY resource to
dump the screen to the printer. From the fkeyhandle,
I get a pointer(fkeyptr) to the FKEY resource that prints the screen.

Does anyone know of a way to reference the 
pointer to the resource in Lightspeed Pascal?
____________________________________________________________

fkeyhandle := GetResource('FKEY',4); 

if not(fkeyhandle = 0) then 
    fkeyptr = fkeyhandle^;	{dereference the handle}
else
  writeln('ERROR! Did not get the resource');

{ Thanks to Ephraim Vishniac @ think.com for the technique }
_____________________________________________________________


Gerald Ngui

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Gerald T. Ngui
University of Wisconsin, Madison

ARPA: geraldn@puff.cs.wisc.edu
      ngui@gumby.cs.wisc.edu
      ngui@daffy.cs.wisc.edu
UUCP: ...!{harvard,ihnp4,seismo,topaz}!uwvax!puff!gerald
      ...!{harvard,ihnp4,seismo,topaz}!uwvax!{gumby,daffy}!ngui
ICBM: 70 82 51 N    88 23 12 W  
CompuServe: 71620, 605
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

rs4u+@andrew.cmu.edu (Richard Siegel) (03/21/88)

If you're trying to actually *call* the FKEY from Lightspeed Pascal, the way to
do it is as follows:

fkeyH := GetResource('FKEY', 4);
if (fkeyH <> NIL) then begin
        MoveHHi(fkeyH);
        HLock(fkeyH);
        CallFKey(fkeyH);
        ReleaseResource(fkeyH);
end;

the procedure "CallFKey" is as follows:

procedure CallFKey(codeH : Handle);
inline $205F, $2050, $4E90;

This bit of code pops the last argument off the stack, dereferences it (into
a0, I think), and JSRs to that address. Notice that you can use the same
technique to call code resources that take multiple arguments...

        -Rich