PreviousNextIndex

Parameter passing syntax

Specifies one or more parameters to pass during invocation of an ABL procedure, a user-defined function, a method of a class (ABL or .NET), a class constructor (ABL or .NET), or the built-in Publish( ) event method or PUBLISH statement to publish class or named events, respectively.

Syntax

( parameter [ , parameter ] ... ) 

The parameters specified by parameter must match in number and order, according to mode and data type, as required by the given procedure, user-defined function, method, or constructor definition. Use the following syntax to specify each parameter:

Syntax
[ INPUT | OUTPUT | INPUT-OUTPUT ] 
{   parm [ AS data-type ] 
  | { {   TABLE temp-table-name 
         | TABLE-HANDLE temp-table-handle  
         | DATASET dataset-name  
         | DATASET-HANDLE dataset-handle  
        } [ APPEND ] [ BY-VALUE | BY-REFERENCE | BIND ]  
     } 
} 

BUFFER buffer 

[ INPUT | OUTPUT | INPUT-OUTPUT ]
parm
AS data-type
TABLE temp-table-name
TABLE-HANDLE temp-table-handle
DATASET dataset-name
DATASET-HANDLE dataset-handle
BUFFER buffer
APPEND
BY-VALUE | BY-REFERENCE | BIND
Examples

The following two code fragments show how the AS data type works when calling an overloaded .NET method, in this case the System.Math:Max( ) method. This static .NET method compares two values of the same data type and returns the largest of the two. The first fragment compiles and runs. It compares the value 50, passed as a System.Byte (specified by the AS data type, UNSIGNED-BYTE), with the maximum value of a System.Byte, returned by the System.Byte:MaxValue data member. The result returned by the Max( ) method is 255, the maximum System.Byte value:

DEFINE VARIABLE iVal1   AS INTEGER NO-UNDO INITIAL 50. 
DEFINE VARIABLE iVal2   AS INTEGER NO-UNDO. 
DEFINE VARIABLE iReturn AS INTEGER NO-UNDO. 
iVal2 = System.Byte:MaxValue. 
iReturn = System.Math:Max( INPUT iVal1 AS UNSIGNED-BYTE,  
                           INPUT iVal2 AS UNSIGNED-BYTE ). 

The second fragment compiles, but returns a run-time error. Again, it passes the same two values to the System.Math:Max( ) method, but this time passes them as a System.SByte (specified by the AS data type, BYTE). A signed byte parameter cannot hold positive values as large as an unsigned byte. So, passing the maximum value of a System.Byte (unsigned byte) as a System.SByte (signed byte) causes the Max( ) method to raise a run-time overflow error:

DEFINE VARIABLE iVal1   AS INTEGER NO-UNDO INITIAL 50. 
DEFINE VARIABLE iVal2   AS INTEGER NO-UNDO. 
DEFINE VARIABLE iReturn AS INTEGER NO-UNDO. 
iVal2 = System.Byte:MaxValue. 
iReturn = System.Math:Max( INPUT iVal1 AS BYTE,  
                           INPUT iVal2 AS BYTE ). /* Run-time error */ 

The following code fragment shows an example of ABL data type widening when passing parameters to a .NET method. This example shows INPUT widening, in this case, passing different ABL data types (INTEGER and INT64) that are acceptable as arguments to a System.Double input parameter:

DEFINE VARIABLE i4Val  AS INTEGER NO-UNDO. 
DEFINE VARIABLE i8Val  AS INT64   NO-UNDO. 
DEFINE VARIABLE iRoot1 AS DECIMAL NO-UNDO. 
DEFINE VARIABLE iRoot2 AS DECIMAL NO-UNDO. 
ASSIGN 
  i4Val  = System.Int32:MaxValue 
  i8Val  = System.Int64:MaxValue 
  iRoot1 = System.Math:Sqrt( INPUT i4Val ) 
  iRoot2 = System.Math:Sqrt( INPUT i8Val ). 

For more information on data type widening, see the Notes section later in this reference entry.

Notes
See also

Assignment (=) statement, Expression, FUNCTION statement, NEW function (classes), Publish( ) event method, PUBLISH statement, RUN statement, RUN SUPER statement, SUPER statement, SUPER system reference, THIS-OBJECT statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex