Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!ucsd!sdcsvax!ucsdhub!btree!brookn From: brookn@btree.uucp (Paul Francis) Newsgroups: comp.lang.pascal Subject: Re: pointers to functions in TP4??? Summary: Get Turbo Pascal 5.0 Message-ID: <315@btree.uucp> Date: 5 Dec 88 17:08:08 GMT References: <10316@umn-cs.CS.UMN.EDU> Reply-To: brookn@btree.UCSD.EDU (Paul Francis) Distribution: na Organization: Brooktree Corporation, San Diego Lines: 64 In article <10316@umn-cs.CS.UMN.EDU> indermau@umn-cs.cs.umn.edu (Kurt Indermaur) writes: > >Is this possible? I'd like to pass a pointer to a procedure (with its para- >meters, ideally) to another procedure, which would then execute the passed >procedure. Something like: > >procedure execute (proc1 : pointer); >begin > . > proc1^; > . >end; Get a copy of Turbo Pascal 5.0 !!!!!! From page 94 of the TP 5.0 reference guide : "Since procedure types are allowed in any context, it is possible to declare procedures or functions that take procedures or functions as parameters." You would use it like this : program test; type call_type : procedure( x, y : integer ); procedure arf( called : call_type ); begin called; end; {$F+} { must be far_call } procedure n1( x, y : integer ); begin ... end; procedure n2( x, y : integer ); begin ... end; {$F-} begin arf( n1 ); arf( n2 ); end. > >Do I have to resort to inline stements, or should I just give up on TP and >write it in C? Give up on pascal !!! are you NUTS !!!!!!! >--Kurt Indermaur -- Paul ( Sicnarf ) Francis backbone!ucsd!btree!brookn "you tried it just for once, found it alright for kicks but now you find out you have a habit that sticks, you're an orgasm addict, you're always at it, and you're an orgasm addict" the Buzzcocks