Useful procedure attributes and methods
- Last Updated: September 12, 2023
- 4 minute read
- OpenEdge
- Version 13.0
- Documentation
There are many procedure attributes you can access through the procedure’s handle. This section introduces you to a few of them.
FILE-NAME attribute
After you run a persistent procedure, you can query its FILE-NAME attribute to see the name of the procedure file, including any pathname it was run with. This attribute can be useful to identify a procedure so that you can run something in its handle or access other attributes.
PRIVATE-DATA attribute
There is a character attribute available on every handle, including procedure
handles, called PRIVATE-DATA. It is there specifically so
that you can store any value you want on the handle, to help identify the object it
points to, or to store other information about the object. The
PRIVATE-DATA attribute is not used by ABL in any way; it is
strictly there for your application use. You could, for example, store a category of
object in the PRIVATE-DATA handle when you run the procedure, or
the value of one or more parameters that were passed in to the procedure to give it
a distinctive function. Because you might run the same procedure file in numerous
ways, for example with different input parameters or different settings that you
establish in other ways, the PRIVATE-DATA attribute gives you the
ability to identify it in any way you need to.
INTERNAL-ENTRIES attribute
The INTERNAL-ENTRIES attribute returns a comma-separated list of all the internal procedures in the procedure file, and also any user-defined functions, which you’ll learn about a little later. This can help you identify the location of a routine you need to run.
GET-SIGNATURE() method
Given the name of any internal procedure or function in a procedure file, you can get its signature, that is, the list of parameters it requires, using the GET-SIGNATURE( ) method on the procedure handle. This is considered a method rather than an attribute simply because it requires an input parameter, the name of the routine you want the signature for. You can also pass in a blank argument to get the signature of the external procedure itself.
GET-SIGNATURE() returns a string in this format:
|
MAINfor the external procedure itself (when you pass in an empty string).PROCEDUREfor an internal procedure.FUNCTIONfor a user-defined function.
The fn-return-type is the data type that a function returns. For an internal procedure, this element of the signature is blank.
- The mode is
INPUT,OUTPUT, orINPUT-OUTPUT. - The name is the parameter name as defined in the entry point.
- The data-type is the data type of the parameter.
|
The h-testsig.p procedure takes an INPUT
parameter, the TestProc internal procedure uses an
OUTPUT parameter, and the TestFunc
function takes an INPUT parameter and returns the data type
INTEGER.
GET-SIGNATURE to get the
signatures of all these routines:
|
- h-mainsig.p runs h-testsig.p persistent and saves off its procedure handle.
- h-mainsig.p gets the
INTERNAL-ENTRIESattribute of the procedure, which should have the valueTestProp,TestFunc. - It begins to build up a character string to display later with a
MESSAGEstatement. The first entry in the message string isTHIS-PROCEDURE:FILE-NAME. Because the built-inTHIS-PROCEDUREsystem handle evaluates to the handle of the currently running procedure, this should return its filename, h-mainsig.p. Passing the empty string toGET-SIGNATUREreturns the signature of the external procedure itself. - The code loops through all the entries in the
INTERNAL-ENTRIESattribute, and for each once, saves off its name and signature. - To simulate a series of
SKIPkeywords that you could put into aMESSAGEstatement, the code adds a new line character after the signature of each entry. TheCHR(n)ABL built-in function takes an INTEGER value that represents the ASCII character code of any character, whether printable or not, and returns that ASCII character. In this case, 10 represents the new line character.
|