SetParameter( ) method (Class)

Populates elements in a Progress.Lang.ParameterList object.

Return type: LOGICAL

Access: PUBLIC

Applies to: Progress.Lang.ParameterList class

Syntax

This method supports two overloaded versions. The first version is used to initialize and populate elements in the ParameterList object. It’s calling sequence is similar to the Call object’s SET-PARAMETER method.

SetParameter ( INPUT position AS INTEGER ,
               INPUT data-type AS CHARACTER ,
               INPUT iomode AS CHARACTER ,
               INPUT parameter-value )

The second overloaded version may ONLY be called if SetParameter has been called before on this parameter, so that data-type and iomode are already initialized.

SetParameter ( INPUT position AS INTEGER ,
               INPUT parameter-value )
position
Identifies the one-based position that the parameter occupies in the routine signature. The AVM returns a run-time error if position is greater than the number of parameters defined for a Progress.Lang.ParameterList object, which was set either during instantiation (passed as input to the constructor) or by setting the NumParameters attribute.
data-type
A CHARACTER expression indicating the target parameter type. This is generally the data type that the invoked method expects, but can also be an AS data type to match an extended .NET data type, such as "SHORT", "BYTE", "SINGLE-CHARACTER", and so on.

If the parameter of the method to be called is type DECIMAL, then data-type should evaluate to "DECIMAL", even if parameter-value is an INTEGER or INT64. You can pass a type that matches the target using the same widening and hierarchy rules that are used during compilation. Using the exact target type will generally result in better performance.

Valid data-type strings are: "CHARACTER", "DATASET", "DATASET-HANDLE", "DATE", "DATETIME", "DATETIME-TZ", "DECIMAL", "HANDLE", "INT64", "INTEGER", "LOGICAL", "LONGCHAR", "MEMPTR", "RAW", "ROWID", "TABLE", "TABLE-HANDLE" or "CLASS object-type-name". A TABLE-HANDLE can be a handle to a static or dynamic TEMP-TABLE. A DATASET-HANDLE can be a handle to a static or dynamic ProDataSet object. The BUFFER type is not supported; use a HANDLE parameter instead.

For any parameter array value, the EXTENT keyword is required when specifying data-type. For example, "CHARACTER EXTENT", "INTEGER EXTENT", "LONGCHAR EXTENT", "MEMPTR EXTENT", "CLASS object-type-name EXTENT" and so on.

For each parameter, the data type specified by the caller and the callee must be compatible with the ABL object-oriented parameter rules.

iomode
A CHARACTER expression that indicates the parameter mode and evaluates to one of the following: "INPUT", "OUTPUT", "INPUT-OUTPUT", "OUTPUT APPEND", "OUTPUT BIND", "INPUT BY-REFERENCE", "OUTPUT BY-REFERENCE", "INPUT-OUTPUT BY-REFERENCE", and "INPUT BIND". For each parameter, the mode specified by the caller and the callee must match. The AVM generates a run-time error if iomode is invalid.

Unlike the call object's SET-PARAMETER( ) method, with the exception of "INPUT-OUTPUT", all iomode combinations are separated by a blank, for example "INPUT BY-REFERENCE".

For more information on parameter modes, see the DEFINE PARAMETER statement or Parameter passing syntax reference entries.

parameter-value
A value of any data type, including the special TABLE and DATASET types. This value must be compatible with data-type. If iomode is OUTPUT or INPUT-OUTPUT, you can only specify a simple variable or property, not an expression. The variable or property must be in scope when the method is invoked using this ParameterList.

Example

The following example demonstrates using the SetParameter() method to construct a parameter list. The first parameter is an input parameter containing the customer number to retrieve. The second and third parameters are output parameters containing the customer name and credit limit for the retrieved customer. GetRecData is a method of class RecData which is invoked by this procedure.

DEFINE VARIABLE plClass AS Progress.Lang.Class.
DEFINE VARIABLE hObj AS Progress.Lang.Object.
DEFINE VARIABLE parms AS CLASS Progress.Lang.ParameterList.
DEFINE VARIABLE custname AS CHARACTER.
DEFINE VARIABLE climit AS INTEGER.
DEFINE VARIABLE custnum AS INTEGER INITIAL 8.
DEFINE VARIABLE retval AS LOGICAL.

/* Create an instance of RecData dynamically */
plClass = Progress.Lang.Class:GetClass("RecData").
hObj = plClass:NEW().

/* Call the GetRecData method dynamically */
parms = NEW Progress.Lang.ParameterList(3).
parms:SetParameter(1, "INTEGER", "INPUT", custnum).
parms:SetParameter(2, "CHARACTER", "OUTPUT", custname).
parms:SetParameter(3, "INTEGER", "OUTPUT", climit).
retval = plClass:INVOKE(hObj, "GetRecData", parms).

IF retval THEN
    MESSAGE "Customer name: " custname
            " Credit limit: " climit 
            VIEW-AS ALERT-BOX.
ELSE
    MESSAGE "Customer not found" 
            VIEW-AS ALERT-BOX.

RecData.cls:

USING Progress.Lang.*.
CLASS RecData INHERITS Progress.Lang.Object:

    METHOD PUBLIC LOGICAL GetRecData 
        (INPUT custnum AS INTEGER,
         OUTPUT custname AS CHARACTER,
         OUTPUT creditlimit AS INTEGER):
         
        DEFINE VAR retval AS LOGICAL INIT TRUE.
        FIND customer WHERE (Customer.custnum = custnum) NO-ERROR.
        IF AVAILABLE Customer THEN
            ASSIGN
                custname = Customer.Name
                creditlimit = Customer.CreditLimit.
        ELSE 
            retval = FALSE.
            
        RETURN retval.            
    END METHOD.
END CLASS.

After running the procedure, the following output is displayed:

Customer name: Game Set Match  Credit limit: 15000

See also

Clear( ) method (Class), Invoke( ) method (Class), New( ) method, NumParameters property (ParameterList)