Progress
Programming
Handbook


Externally Defined User-defined Functions

Progress lets procedures reference user-defined functions whose definitions reside in external procedures. The following example, which consists of two procedures, illustrates this.

The first procedure, p-udfdef.p, defines doubler():

p-udfdef.p
/* Defines user-defined function doubler() */ 
FUNCTION doubler RETURNS INTEGER (INPUT parm1 AS INTEGER). 
  RETURN (2 * parm1).  
END FUNCTION.  

The second procedure, p-udf3.p, runs the first procedure persistently, declares doubler(), references it, and deletes the persistent procedure—in that order:

p-udf3.p
/* references an externally-defined user-defined function */ 
/* define items */ 
DEFINE VARIABLE myhand AS HANDLE. 
DEFINE VARIABLE mystr  AS CHARACTER FORMAT "x(20)". 
/* forward declare doubler() */ 
FUNCTION doubler RETURNS INTEGER (INPUT parm1 AS INTEGER) IN myhand.  
/* run the procedure that doubler() */ 
RUN src\prodoc\langref\p-udfdef.p PERSISTENT SET myhand.  
/* reference doubler() */ 
DISPLAY  "doubler(0)=" doubler(0) skip 
        "doubler(1)=" doubler(1) skip 
        "doubler(17)=" doubler(17) skip. 
/* delete the procedure that defines doubler */ 
DELETE PROCEDURE(myhand).    


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095