Try OpenEdge Now
skip to main content
ABL Reference
Handle Reference : THIS-PROCEDURE system handle
 

THIS-PROCEDURE system handle

A handle to the procedure object for the currently executing procedure. This object allows you to read and modify the context of the current procedure.

Syntax

THIS-PROCEDURE [ :attribute | :method ]
attribute
An attribute of THIS-PROCEDURE.
method
Specifies a method of THIS-PROCEDURE.

Attributes

The THIS-PROCEDURE handle supports all the attributes of the procedure object handle. For a list of these attributes, see the reference entry for the Procedure object handle in this section.

Methods

The THIS-PROCEDURE handle supports all the methods of the procedure object handle. For a list of these methods, see the reference entry for the Procedure object handle in this section.

Example

The following procedure is designed to run both persistently and non-persistently. It sets up a query on the Customer table of the Sports2000 database that is selectable by Name or Balance.
r-thispr.p
DEFINE VARIABLE custwin AS HANDLE.

DEFINE QUERY custq FOR Customer.
DEFINE BROWSE custb QUERY custq
  DISPLAY Customer.Name Customer.Balance Customer.Phone WITH 10 DOWN.

DEFINE BUTTON bName    LABEL "Query on Name".
DEFINE BUTTON bBalance LABEL "Query on Balance".
DEFINE BUTTON bCancel  LABEL "Cancel".

DEFINE FRAME CustFrame custb SKIP
  bName bBalance bCancel.

ON CHOOSE OF bName IN FRAME CustFrame DO:
  custwin:TITLE = "Customers by Name".
  OPEN QUERY custq FOR EACH Customer BY Customer.Name.
END.

ON CHOOSE OF bBalance IN FRAME CustFrame DO:
  custwin:TITLE = "Customers by Balance".
  OPEN QUERY custq FOR EACH Customer BY Customer.Balance DESCENDING.
END.

IF THIS-PROCEDURE:PERSISTENT THEN DO:
THIS-PROCEDURE:PRIVATE-DATA = "Customer Browse".
  CREATE WIDGET-POOL.
END.

CREATE WINDOW custwin ASSIGN
  TITLE            = "Customer Browser"
  SCROLL-BARS      = FALSE
  MAX-HEIGHT-CHARS = FRAME CustFrame:HEIGHT-CHARS
  MAX-WIDTH-CHARS  = FRAME CustFrame:WIDTH-CHARS.

THIS-PROCEDURE:CURRENT-WINDOW = custwin.

ENABLE ALL WITH FRAME CustFrame.

IF THIS-PROCEDURE:PERSISTENT THEN
  ON CHOOSE OF bCancel IN FRAME CustFrame DO:
    RUN destroy-query.
  END.
ELSE
  WAIT-FOR CHOOSE OF bCancel IN FRAME CustFrame.

PROCEDURE destroy-query:
  DELETE PROCEDURE THIS-PROCEDURE.
  DELETE WIDGET-POOL.
END PROCEDURE.
The procedure uses the THIS-PROCEDURE handle to distinguish between persistent and non-persistent instances of execution. When r-thispr.p is persistent (THIS-PROCEDURE:PERSISTENT = TRUE), it:
*Sets the PRIVATE-DATA attribute to help identify it to other procedures.
*Creates a private widget pool to maintain its dynamic window for as long as the procedure instance persists.
*Defines a trigger to delete the procedure when it is terminated. Note that the trigger calls the internal procedure destroy-query, which can be executed by other external procedures to delete r-thispr.p when it is persistent. This destroy-query routine references the THIS-PROCEDURE handle to delete its persistent parent. It also deletes the widget pool that maintains the dynamic window.
When r-thispr.p is non-persistent (THIS-PROCEDURE:PERSISTENT = FALSE), it invokes a WAIT-FOR statement rather than defining a trigger to terminate the procedure. It does not need to create a widget pool or maintain any other persistent context.
Note that because both persistent and non-persistent instances of this procedure use a dynamic window separate from the default window, r-thispr.p assigns the window's handle to the procedure's CURRENT-WINDOW attribute. This makes the dynamic window current whether or not the procedure is persistent. However, when the procedure is persistent, the CURRENT-WINDOW attribute keeps the dynamic window current while other procedures execute using different windows. Because the persistent procedure has its own current window, its triggers and internal procedures do not have to reset the current window every time they execute.

Notes

*By determining if the current procedure is persistent, you can decide whether or not to perform certain actions. An action that you might perform during a non-persistent procedure is to execute a WAIT-FOR statement to provide input-blocking. Actions that you might execute during a persistent procedure include creating a new window to parent all other widgets created in the procedure, or maintaining an unscoped record buffer that lasts as long as the procedure persists.
*To create an instance of a persistent procedure, use the PERSISTENT option of the RUN statement. For an example, see the reference entry for the Procedure object handle in this section.
*If THIS-PROCEDURE is persistent and the NEXT-SIBLING or PREV-SIBLING attributes are invalid, THIS-PROCEDURE specifies the last or first persistent procedure instance (respectively) in the session persistent procedure chain. To check the validity of these attributes, use the VALID-HANDLE function.

See also

Procedure object handle, RUN statement, SESSION system handle, VALID-HANDLE function