Procedure as parameter in procedure 
Author Message
 Procedure as parameter in procedure

Hi,

I'm trying to figure out how to use a procedure as a parameter in a
procedure. I'd be very thankful to anyone who takes the trouble of
giving me a simply example.

Thanks,

Helle

Hjemmeside/Homepage: http://www.*-*-*.com/ ~haugenes/



Thu, 09 Nov 2000 03:00:00 GMT  
 Procedure as parameter in procedure


 HH> I'm trying to figure out how to use a procedure as a parameter in a
 HH> procedure. I'd be very thankful to anyone who takes the trouble of
 HH> giving me a simply example.

 Look at the following Extended Pascal example:

 program ffexpm ( input, output ) ;
 var a,b,c,d,e,f: real ;
     s : string ( 20 ) ;

   function func1 ( p1, p2 : real ) : real ;
   begin
        func1 := sqr(p1) + sqr(p2) ;
   end ;

   function func2 ( p1, p2 : real ) : real ;
   begin
        func2 := sqr(p1) + sqr(p2) + p1 * p2 ;
   end ;

   function func3 ( p1, p2 : real ) : real ;
   begin
        func3 := sqr(p1) + sqr(p2) - p1 ** p2 ;
   end ;

   function func ( function p ( p1, p2:real ):real; p1,p2:real ):real ;
   begin
      func := sqr ( p ( p1, p2 ) ) ;
   end ;

 begin
      writeln (' Please enter values for a,b,c,d,e,f:' ) ;
      readln ( a,b,c,d,e,f ) ;
      writeln ( func( func1,a,b ):15:10, ' ', func(func2,c,d):15:10,
             ' ', func(func3,e,f):15:10 ) ;
 end.

 Kind regards
 F. Pluennecke

 -----------------------------------------------------------------------------

 Hinterm Dorfe 21           Fax: 49-5174-92101        http://www.pluennecke.de
 D-38268 Lengede   Pascal-Info: http://www.pluennecke.de/prospero/proindex.htm
 -----------------------------------------------------------------------------



Thu, 09 Nov 2000 03:00:00 GMT  
 Procedure as parameter in procedure


 HH> I'm trying to figure out how to use a procedure as a parameter in a
 HH> procedure. I'd be very thankful to anyone who takes the trouble of
 HH> giving me a simply example.

 Look at the following Extended Pascal example (it uses functions instead
of procedures, but demonstrates the method) :

 program ffexpm ( input, output ) ;
 var a,b,c,d,e,f: real ;
     s : string ( 20 ) ;

   function func1 ( p1, p2 : real ) : real ;
   begin
        func1 := sqr(p1) + sqr(p2) ;
   end ;

   function func2 ( p1, p2 : real ) : real ;
   begin
        func2 := sqr(p1) + sqr(p2) + p1 * p2 ;
   end ;

   function func3 ( p1, p2 : real ) : real ;
   begin
        func3 := sqr(p1) + sqr(p2) - p1 ** p2 ;
   end ;

   function func ( function p ( p1, p2:real ):real; p1,p2:real ):real ;
   begin
      func := sqr ( p ( p1, p2 ) ) ;
   end ;

 begin
      writeln (' Please enter values for a,b,c,d,e,f:' ) ;
      readln ( a,b,c,d,e,f ) ;
      writeln ( func( func1,a,b ):15:10, ' ', func(func2,c,d):15:10,
             ' ', func(func3,e,f):15:10 ) ;
 end.

 Kind regards
 F. Pluennecke

 -----------------------------------------------------------------------------

 Hinterm Dorfe 21           Fax: 49-5174-92101        http://www.pluennecke.de
 D-38268 Lengede   Pascal-Info: http://www.pluennecke.de/prospero/proindex.htm
 -----------------------------------------------------------------------------



Fri, 10 Nov 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Passing a pointer to a procedure/function as a parameter in a procedure

2. Need examples of recordset from stored procedure with parameters

3. Passing parameters to stored procedure.

4. ADOExpress Stored procedure parameters (TeamB - any ideas?)

5. Passing TMemoField as a TStringList parameter to a procedure

6. Send a procedure like parameter

7. newbie : optional parameters for procedures

8. parameters and procedures

9. Parameters in extended stored procedures using Open Data Services, urgent

10. Passing NULL parameters to a stored procedure

11. Q. Procedure with OPTIONAL parameters

12. optional parameters in procedures?

 

 
Powered by phpBB® Forum Software