Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!agate!ucbvax!unisoft!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Variable procedures in Pascal Message-ID: <13948@hoptoad.uucp> Date: 30 Nov 90 17:39:42 GMT References: <1990Nov23.082345.12074@portia.Stanford.EDU> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Electronics for Imaging, San Bruno CA Lines: 29 In article <1990Nov23.082345.12074@portia.Stanford.EDU> ralphm@elaine19.stanford.edu (Ralph Melton) writes: >I am using Think Pascal 3.01, and I really want to be able to declare >procedural variables. > >I believe that it is possible to do such things in C, and I know about >procedural parameters in Pascal. I also know that I can pass some Toolbox >routines the address of a procedure. Is there any way to do what I want >within THINK Pascal? Sure, but you need a little inline assembler. Declare the procedure variables as type ProcPtr (for internal documentation purposes). Then declare an inline routine that takes the parameters of the routine you are calling, plus an extra routine that's the ProcPtr. The inline assembler pops the routine address off the stack and jsr's to it. For example: function CallWombatNipple (operator: longint; params: Handle; routine: ProcPtr): Handle; inline $205F, $4E90; { MOVE.L (A7)+,A0; JSR (A0) } This is a way to call a routine that is declared as: function WombatNipple (operator: longint; params: Handle): Handle; -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com The fact is self-evident from the text and requires no supporting argument.