Note:
DEFINE INPUT OUTPUT INPUT-OUTPUT RETURN PARAMETER parameterAS HANDLE TO primitive-type-nameAS CLASS object-type-nameLIKE field EXTENT constantNOT CASE-SENSITIVEFORMAT stringDECIMALS nINITIALconstant [ constant , constant ]COLUMN-LABEL labelLABEL stringNO-UNDO
DEFINE PARAMETER BUFFER buffer-name FOR TEMP-TABLE table-namePRESELECT
DEFINE INPUT OUTPUT INPUT-OUTPUT PARAMETERTABLE FOR temp-table-name APPEND BIND BY-VALUETABLE-HANDLE temp-table-handle BIND BY-VALUEDATASET FOR dataset-name APPEND BIND BY-VALUEDATASET-HANDLE dataset-handle BIND BY-VALUEAS HANDLE TO primitive-type-nameFor ABL procedures, primitive-type-name can specify any built-in primitive type used to define variables. For more information on the available primitive types, see the Data types reference entry. For more information on defining primitive type variables, see the DEFINE VARIABLE statement reference entry.For DLL or UNIX shared library routines, primitive-type-name can specify an ABL DLL data type. ABL DLL data types include the built-in ABL data types CHARACTER and MEMPTR, Windows DLL-equivalent data types, and UNIX shared library data types.Table 31 shows how Windows DLL and UNIX shared library data types map to ABL DLL data types.
char BYTE short SHORT unsigned shortint UNSIGNED-SHORT long (32-bit UNIX, Win32) LONG2 unsigned int UNSIGNED-LONG __int64 (Win32)long long (UNIX 32-bit)long (UNIX 64-bit)
INT64 float FLOAT double DOUBLE char* CHARACTER c-data-type3 HANDLE TO parameter-data-type3 MEMPTR
The C data type int generally specifies a size that depends on the operating system.
To pass a null pointer value to a DLL routine, pass 0 using a LONG parameter. Do not use a null MEMPTR variable to pass a null value. However, you can pass a null value in one or more elements of a MEMPTR array. If this conflicts with another way to call the DLL routine, specify a second declaration for the same routine using the ORDINAL option of the PROCEDURE statement.
You can use the HANDLE TO option to specify a pointer to a primitive type. Therefore, you can use the HANDLE TO option with the parameter data types (that is, BYTE, SHORT, UNSIGNED-SHORT, LONG, FLOAT, and DOUBLE) in order to specify a pointer to the respective C data types (that is, char, short, unsigned short, long, int, float, and double). For a CHARACTER or MEMPTR parameter, it is redundant because this data type is always passed using a pointer (char*).
Note: You cannot use RETURN for any type of array parameter.For ActiveX control event procedures, primitive-type-name can specify the built-in ABL data type that maps to the COM object data type of an ActiveX event parameter. Table 32 shows how the COM object data types for event parameters (shown as ActiveX data types) map to ABL data types.
ActiveX data type1 <ANYTYPE>2
For more information on these data type implementations for COM objects, see OpenEdge Development: Programming Interfaces.
AS CLASS object-type-nameDefines the parameter as an object reference with the data type of a class or interface. The default value of the parameter is the Unknown value (?). You cannot assign an initial value using the INITIAL option.Specifies the type name of an ABL or .NET class or interface. Specify an object type name using the syntax described in the Type-name syntax reference entry. With an appropriate USING statement, you can also specify a class or interface name alone, without the qualifying package or namespace.For a class or interface return value, ABL passes an object reference associated with the class or interface, not a class instance itself. For more information on object references, see the Class-based object reference reference entry.For descriptions of these options, see the DEFINE VARIABLE statement reference entry.EXTENT constantDefines the parameter as an array of data elements, where the element data type is specified by the AS primitive-type-name option, the LIKE field option, or the AS object-type-name option. This option can specify an array parameter as either determinate (has a defined number of elements) or indeterminate (has an undefined number of elements). To define a determinate array parameter, specify the EXTENT option with the constant argument. This optional argument is an integer value that represents the number of data elements in the array parameter. To define an indeterminate array parameter, specify the EXTENT option without the constant argument.The EXTENT is part of the parameter data type. For more information, see the Type-name syntax reference entry.If you are using the AS option and you do not use the EXTENT option (or you specify constant as 0), the parameter is not an array parameter. If you are using the LIKE field option and you do not use the EXTENT option, the parameter uses the extent defined for the database field you name (if any).Defines a buffer parameter, where buffer-name is the name you specify for the buffer and table-name is the name of a temp-table or database table. You can pass a buffer associated with a database table to a buffer parameter. You cannot pass a work table to a buffer parameter. A buffer parameter is always INPUT-OUTPUT. You cannot pass buffer parameters to the AppServer.TABLE FOR temp-table-nameFor more information about passing a temp-table parameter by reference or by binding, see the Parameter passing syntax reference entry. For more information about temp-table parameters, see OpenEdge Getting Started: ABL Essentials.TABLE-HANDLE temp-table-handleDATASET dataset-nameFor more information about passing a ProDataSet object parameter by reference or by binding, see the Parameter passing syntax reference entry. For more information on ProDataSet object parameters, see OpenEdge Development: ProDataSets.DATASET-HANDLE dataset-handleFor more information about passing these parameters by binding, see the Parameter passing syntax reference entry.Specified for an INPUT, OUTPUT, or INPUT-OUTPUT TABLE, TABLE-HANDLE, DATASET, or DATASET-HANDLE parameter in a called routine, this option forces the parameter to be passed to the local routine by value, which overrides any BY-REFERENCE option in the corresponding routine invocation. For more information on BY-REFERENCE, see the Parameter passing syntax reference entry.In the following examples, the r-runpar.p procedure runs a subprocedure called r-param.p and passes the subprocedure an INPUT parameter. The subprocedure r-param.p displays the INPUT parameter.
RUN r-param.p (INPUT 10).
DEFINE INPUT PARAMETER int-param AS INTEGER NO-UNDO.
DISPLAY int-param LABEL "Integer input param"WITH SIDE-LABELS.In the following example, the r-runpr1.p procedure runs a subprocedure called r-param1.p. This example illustrates the use of multiple parameters and shows that the parameters must be passed in the proper order and must be of the same data type. Note that if you do not specify a parameter type in the RUN statement, the AVM assumes it is an input parameter.In the following example, the r-runpr2.p procedure displays information from a database table and assigns the value of a database field to a variable called io-param. The variable is passed as an INPUT-OUTPUT parameter to a subprocedure called r-param2.p. The subprocedure r-param2.p performs a calculation on the INPUT-OUTPUT parameter, then passes it back to the main procedure. The r-runpr2.p assigns the value io-param to a database field, then displays io-param.
DEFINE INPUT-OUTPUT PARAMETER io-param AS INTEGER NO-UNDO.
DEFINE VARIABLE inp-qty AS INTEGER NO-UNDO.PROMPT-FOR inp-qty LABEL "Quantity Received?".ASSIGN inp-qty.io-param = io-param + inp-qty.The following example uses a buffer parameter. The procedure r-bufp.p passes the Customer buffer to the getCustomer internal procedure, which attempts to find a record using that buffer.The following example defines parameters for the DLL routine, MessageBox, which displays a message on the screen:For more information about passing parameters by reference or by binding, see the Parameter passing syntax reference entry.
The LIKE field option can only specify a database field of type CHARACTER or a variable of type CHARACTER or MEMPTR.
For more information on DLL routine parameters and how they map to ABL data types, see the chapter on DLLs in OpenEdge Development: Programming Interfaces.
For more information on ActiveX event parameters, or using COM objects, see the chapter in OpenEdge Development: Programming Interfaces.
If the parameter is OUTPUT TABLE-HANDLE, the called routine sends back the definition behind the handle along with the contents of the output temp-table. In the caller, if the original handle was the Unknown value (?), a new instance of the temp-table is created and populated with the output contents. The temp-table object is created in the default widget-pool of the caller’s OpenEdge session. To avoid memory leaks, the temp-table object must be manually destroyed. For more information on deleting objects, see the reference entry for the DELETE OBJECT statement.If the original handle is not the Unknown value (?), the caller’s existing table must match the table being received from the called routine.
If you call a remote procedure asynchronously (using the ASYNCHRONOUS option of the RUN statement) and pass a parameter as OUTPUT TABLE-HANDLE temp-table-handle APPEND, the event procedure must specify a corresponding DEFINE INPUT PARAMETER TABLE-HANDLE FOR temp-table-handle APPEND statement, and temp-table-handle must be global to both the calling procedure and the event procedure.
For more information on working with asynchronous remote procedures and event procedures, see OpenEdge Application Server: Developing AppServer Applications.If the parameter is OUTPUT DATASET-HANDLE, and the caller’s handle is the Unknown value (?), no definition is sent to the called routine.
If the parameter is OUTPUT DATASET-HANDLE, the called routine sends back the definition behind the handle along with the contents of the output ProDataSet object. In the caller, if the original handle is the Unknown value (?), a new instance of the ProDataSet object is created and populated with the output contents. If the original handle is not the Unknown value (?), the caller’s existing object must match the object being received from the called routine.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |