[comp.sys.mac.programmer] use of code resources

jboser@cs.fau.edu (Jeff Boser) (06/12/91)

Could someone please send me information about how to call a code resource?
I want to make a program that uses code resources.  I know I have to load
the resource and lock it, and somehow do a jump to it, but I am ignorant
as to the exact methods.  for example, how do I pass the two parameters, two
longs?

thanks in advance for any help.

.....jeff
jboser@tuna.cs.fau.edu
-- 
"Make something an idiot can use, and only an idiot will use it." - RAH
Like a bible, maybe? - me

pete@netcom.COM (Peter O'leary) (06/12/91)

From article <1991Jun11.212111.21613@cs.fau.edu>, by jboser@cs.fau.edu (Jeff Boser):
> 
> Could someone please send me information about how to call a code resource?
> I want to make a program that uses code resources.  I know I have to load
> the resource and lock it, and somehow do a jump to it, but I am ignorant
> as to the exact methods.  for example, how do I pass the two parameters, two
> longs?

I use something like this (in C):

typedef void (*ptr_to_procedure)(long n1, long n2);

...

{
	ptr_to_procedure p;
	Handle code_resource = Get1Resource('CODE', 128);

	HLock(code_resource);
	p = *code_resource;

	(*p)(1, 2);
}

This is not actually a Mac problem: how you accomplish the call depends
entirely on which language you are using. I can't remember offhand how
you would do it in Pascal.

-- 
   Pete O'Leary                     *  My opinions are not my own, I am a
  pete@netcom.com                   *  victim of media manipulation.