For more information on the rules that ABL uses to search for internal procedures and user-defined functions, see the “Search rules” section. For a sample program that uses the ADD-SUPER-PROCEDURE method, see the reference entry for the RUN SUPER statement.
Return type:
Applies to:
ADD-SUPER-PROCEDURE ( super-proc-hdl , proc-search )ADD-SUPER-PROCEDURE returns FALSE if super-proc-hdl is not a valid handle, or if the AVM detects that the method was not successful. Otherwise, the method returns TRUE.
SEARCH-TARGET starts searching the super procedures of the procedure file that originally invoked the current internal procedure or user-defined function (the procedure with the original RUN statement). If the procedure was RUN . . . IN procedure-handle, SEARCH-TARGET searches the super procedures of procedure-handle.
A given super-proc-hdl can be added as either SEARCH-TARGET or SEARCH-SELF, but cannot be added as both. If proc-search is set for a super-proc-hdl, then any attempt to change its value generates a run-time warning, but the ADD-SUPER-PROCEDURE( ) method succeeds. The warning message “Changing proc-search-string for procedure <.p-name> from <string> to <string>” is presented to indicate that the application is using an instance of a given super procedure in an inconsistent manner. This warning message can be suppressed by using the SESSION:SUPPRESS-WARNINGS-LIST attribute. In addition, the warning message can be avoided by creating two instances of super-proc-hdl, one identified as SEARCH-TARGET and the other identified as SEARCH-SELF.
THIS-PROCEDURE:ADD-SUPER-PROCEDURE(my-super-proc-hdl,SEARCH-SELF).
local-proc-hdl:ADD-SUPER-PROCEDURE(my-super-proc-hdl,SEARCH-TARGET).The procedure to which you add a super procedure is called the local procedure of the super procedure.
SESSION:ADD-SUPER-PROCEDURE(my-super-proc-hdl).
THIS-PROCEDURE:ADD-SUPER-PROCEDURE(super-proc-hdl).
SESSION:ADD-SUPER-PROCEDURE(super-proc-hdl).A collection of super procedure handles associated with a local procedure or with the current ABL session is called a super procedure stack. The handle of the most recently added super procedure occupies the top of the stack.When you add a super procedure to a super procedure, the result is a super procedure chain, each link of which consists of two elements: a local procedure and its super procedure. When the AVM searches a super procedure chain, it does not proceed to the next link unless the current link’s super procedure element explicitly invokes its super version (by using the RUN SUPER statement or the SUPER function).The AVM searches for internal procedures and user-defined functions depending on how the internal procedure or user-defined function is invoked. The search rules illustrated in the first three cases assume that all the super procedures were added with no proc-search value or with a proc-search value of SEARCH-SELF. The fourth case illustrates the search process when a super procedure is added with a proc-search value of SEARCH-TARGET.Case 1: When the AVM encounters a statement like the following:
RUN add-record('Customer').
4. Case 2: When the AVM encounters a statement like the following:
RUN add-record IN my-proc-hdl('Customer').Case 3: When the AVM encounters a statement like the following:
add-record('Customer').
Note: The rules of Case 3 apply whether or not the user-defined function’s declaration (function prototype) includes the IN proc-hdl option. In Case 3, proc-hdl represents the local procedure. For more information on function prototypes of user-defined functions, see OpenEdge Getting Started: ABL Essentials.Case 4: A procedure, main.p, has added three super procedures, S1, S2, and S3 (in that order). Each of these super procedures has added its own super procedures, S1A, S1B, S2A, S2B, S3A, S3B. The procedure, add-record, exists in three places: in S1, in S2 where it contains a RUN SUPER statement, and in S2A.When the AVM encounters a statement like "RUN add-record(’customer’).", it searches for the add-record procedure:The following code for main.p shows the differences in the initial setup of this case, which compares the use of no proc-search value (Instance 1) with the use of a value of SEARCH-TARGET (Instance 2):If S2 was added with no proc-search value (Instance 1, commented out) or with a proc-search value of SEARCH-SELF, when RUN SUPER is executed within add-record in S2, the AVM starts searching in S2A, which is next in the search stack of the super procedure, S2.If S2 was added with a proc-search value of SEARCH-TARGET (Instance 2, as executed), when RUN SUPER is executed within add-record in S2, the AVM starts searching in S1, which is next in the search stack of the local procedure, main.p.
Note: The search commences with the super procedure following super-proc-hdl in the local procedure’s search stack.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |